Esempio n. 1
0
void FileService::save(const QString& path, const QString& ext)
{
	if(path == "") {
		this->saveAs();
	}
	else {
        try {
            WindowService* ws = dynamic_cast<WindowService*>(_gi->getService(GenericInterface::WINDOW_SERVICE));
            if(ws != NULL) {
                StandardImageWindow* imw = dynamic_cast<StandardImageWindow*>(ws->getCurrentImageWindow());
                if(imw != NULL) {
					try {
						imw->getImage()->save(path.toStdString()); 
					}
					catch(const UnknownFormatException& e) {
						if(ext == "")
							throw e;
						
						imw->getImage()->save((path+ext).toStdString()); 
					}
                }
                else {
                    QMessageBox::critical(_gi, "Bad object type", "Only images can be saved at the moment.");
                }
            }
        }
        catch(const char* s) {
                QMessageBox::information(_gi, "plop", s);
        }
	}
}
Esempio n. 2
0
void UtilityService::showPixelsGrid()
{
	WindowService* ws = dynamic_cast<WindowService*>(_gi->getService(GenericInterface::WINDOW_SERVICE));
	StandardImageWindow* curWindow = NULL;
	
	if(ws && (curWindow = dynamic_cast<StandardImageWindow*>(ws->getCurrentImageWindow()))) {
		curWindow->showPixelsGrid();
	}
}
Esempio n. 3
0
void BitPlaneService::applyBitPlane()
{ 
    StandardImageWindow* siw = dynamic_cast<StandardImageWindow*>(_ws->getCurrentImageWindow());
    if (siw != NULL)
    {
        const Image* im = siw->getImage();
        Image* im_selected = im->crop(siw->getSelection());
        _bitplanewindow = new BitPlaneWindow("", _gi, im_selected);
        emit newImageWindowCreated(_ws->getNodeId(siw), _bitplanewindow);
    }
}
Esempio n. 4
0
StandardImageWindow::StandardImageWindow(const StandardImageWindow& siw, imagein::Image* image)
    : ImageWindow(siw.getPath())
{
    if(image == NULL) {
        image = new Image(*siw._displayImg);
    }

    this->setDisplayImage(image);
    this->setWindowTitle(siw.windowTitle());

    init();
}
Esempio n. 5
0
void WindowService::addFile(const QString& path)
{
    QMutexLocker locker(&_mutex);
    StandardImageWindow* siw = new StandardImageWindow(path);
    const Image* img = siw->getImage();
    if(img->size() == 0) {
        delete siw;
    }
    else {
        this->addImage(img, siw);
    }
}
Esempio n. 6
0
void AlgorithmService::applyAlgorithm(GenericAlgorithm_t<Image::depth_t>* algo)
{
    StandardImageWindow* siw = dynamic_cast<StandardImageWindow*>(_ws->getCurrentImageWindow());
    if (siw != NULL)
    {
        const Image* whole_image = siw->getImage();
        const Image* im = whole_image->crop(*(siw->getSelection()));
        QString name = _ws->getWidgetId(siw);

        Image* im_res = (*algo)(im);
        //im_res = Converter<Image>::makeDisplayable(*im_res);

        StandardImageWindow* siw_res = new StandardImageWindow(name, _gi, im_res);
        emit newImageWindowCreated(name, siw_res);
    }
}
void ComponentLabelingService::applyAlgorithm(ComponentLabeling* algo)
{
    StandardImageWindow* siw = dynamic_cast<StandardImageWindow*>(_ws->getCurrentImageWindow());
    if (siw != NULL)
    {
        const Image* im = Converter<GrayscaleImage>::convert(*(siw->getImage()));
        NodeId nodeId = _ws->getNodeId(siw);
        RgbImage* im_res = (*algo)(im);
        StandardImageWindow* siw_res = new StandardImageWindow(siw->getPath(), _gi, im_res);
        siw_res->setWindowTitle(siw->windowTitle() + " [component labeling]");
        _ws->addImage(nodeId, siw_res);

        ResultWidget* r = new ResultWidget(algo->getNbComponents(), algo->getAverageComponentSize(), _gi);
        r->setWindowTitle(siw_res->windowTitle()+" - Statistiques");
        _ws->addWidget(nodeId, r);
    }
}
void BinarizationService::applyBinarization()
{
    StandardImageWindow* siw = dynamic_cast<StandardImageWindow*>(_ws->getCurrentImageWindow());
    if (siw != NULL)
    {
        if (siw->getImage()->getNbChannels() != 1)
        {
            QMessageBox::information(siw,
                                     "Attention",
                                     "You want to binarize a non grayscale image, it's impossible. You should first transform it.");
        }
        else
        {
            _binWidget = new BinarizationWidget(siw, _ws->getWidgetId(siw));
            QObject::connect(_binWidget, SIGNAL(exportBinarizedImage(QString&,Image*)),
                             this, SLOT(exportBinarizedImage(QString&,Image*)));
            _ws->addWidget(_ws->getWidgetId(siw), _binWidget);
        }
    }
}