Exemplo n.º 1
0
void ImageWidget::redo()
{
	if (m_stack->canRedo()) {
		m_stack->redo();
		updateImageLabel();
	}
}
Exemplo n.º 2
0
void ImageWidget::undo()
{
	if (m_stack->canUndo()) {
		m_stack->undo();
		updateImageLabel();
	}
}
Exemplo n.º 3
0
void ImageWidget::setImage(const QImage &image) {
	m_image = image;
	m_stack->clear();
	m_filePath = QString();
	setWindowTitle(tr("無題"));
	updateImageLabel();
}
Exemplo n.º 4
0
void MainWindow::setArrowObjects(std::vector<std::shared_ptr<Object>> object)
{
	mArrowObjects = object;

	std::sort(mArrowObjects.begin(), mArrowObjects.end(), [](std::shared_ptr<Object> a, std::shared_ptr<Object> b) {
		return b->x() > a->x();
	});
	
	std::ofstream out("result.txt");
	for (auto& i : mArrowObjects)
	{
		i->resize(33, 33);

		drawRectangle(i->x(), i->y(), i->width(), i->height());
		out << " Object: " << i->x() << "->" << i->width() << ":" << i->y() << "->" << i->height() << std::endl;
		out << i->printImage();
	}
	
	// clear x min


	// clear x max


	updateImageLabel(mCurrentImage, mImageLabel, 0, 0);
	out << "End" << std::endl;
	out.close();

	if (mSegmentationForm != nullptr)
	{
		disconnect(mSegmentationForm.get(), SIGNAL(getArrowObjects(std::vector<std::shared_ptr<Object>>)), this, SLOT(setArrowObjects(std::vector<std::shared_ptr<Object>>)));
	}
}
Exemplo n.º 5
0
void ImageWidget::autoImageResize()
{
	const qreal magnificationX = static_cast<qreal>(size().width() - 2) / static_cast<qreal>(m_image.width());
	const qreal magnificationY = static_cast<qreal>(size().height() - 2) / static_cast<qreal>(m_image.height());
	m_magnification = qMin(qMax(qMin(magnificationX, magnificationY), common::MAGNIFICATION_MIN), common::MAGNIFICATION_MAX);
	updateImageLabel();
	emitZoomStateChanged();
}
Exemplo n.º 6
0
VisionGUI::VisionGUI(OptionManager &mgr,
                     const std::string &descrName, const std::string &tagName) :
    VisionBrainComponentI(mgr, descrName, tagName) {

    ui.setupUi(this);
    connect (ui.actionExit, SIGNAL(triggered()), this, SLOT(close()));
    connect (this, SIGNAL(imageReady()), this, SLOT(updateImageLabel()));
    connect (ui.actionSave_Frame_as_Image, SIGNAL(triggered()), this, SLOT(saveImage()));
}
Exemplo n.º 7
0
void MainWindow::setImage(std::shared_ptr<QImage> image)
{
	mCurrentImage = image;
	updateImageLabel(image, mImageLabel, 0, 0);
    if(mFiltrationForm != nullptr)
    {
        disconnect(mFiltrationForm.get(), SIGNAL(getImage(std::shared_ptr<QImage>)), this, SLOT(setImage(std::shared_ptr<QImage>)));
    }    
}
Exemplo n.º 8
0
void ImageWidget::zoom(qreal m)
{
	if (m >= common::MAGNIFICATION_MAX) { m = common::MAGNIFICATION_MAX; }
	if (m <= common::MAGNIFICATION_MIN) { m = common::MAGNIFICATION_MIN; }
	m_magnification = m;
	setAutoImageResize(false);
	updateImageLabel();
	emitZoomStateChanged();
}
Exemplo n.º 9
0
void ImageWidget::filterInsertRandomNoise()
{
	InsertRandomNoiseDialog dialog(this);
	if (dialog.exec() == dialog.Accepted) {
		const double density = dialog.getDensity();
		CommandFilter *cmd = new CommandFilter(new FilterInsertRandomNoise(density), &m_image, tr("ランダムノイズの挿入"));
		m_stack->push(cmd);
	}
	updateImageLabel();
}
Exemplo n.º 10
0
bool ImageWidget::load(const QString &filePath)
{
	if (!m_image.load(filePath)) {
		return false;
	}
	m_image.convertToFormat(QImage::Format_RGB888, Qt::ColorOnly);
	m_stack->clear();
	m_filePath = filePath;
	setWindowTitle(QFileInfo(filePath).fileName());
	updateImageLabel();
	return true;
}
Exemplo n.º 11
0
void ImageWidget::normFilter()
{
	NormFilterDialog dialog(this);
	if (dialog.exec() == dialog.Accepted) {
		const QVector< QVector<int> > maskX(dialog.getMatrixX());
		const QVector< QVector<int> > maskY(dialog.getMatrixY());
		if (maskX.isEmpty() || maskY.isEmpty()) { return; }
		CommandFilter *cmd = new CommandFilter(new NormFilter(maskX, maskY), &m_image, tr("ノルムフィルタ"));
		m_stack->push(cmd);
	}
	updateImageLabel();
}
Exemplo n.º 12
0
void ImageWidget::linearFilter()
{
	LinearFilterDialog dialog(this);
	if (dialog.exec() == dialog.Accepted) {
		const QVector< QVector<int> > mask(dialog.getMatrix());
		const int denominator = dialog.getDenominator();
		const bool absolute = dialog.getAbsolute();
		if (mask.isEmpty() || denominator == 0) { return; }
		CommandFilter *cmd = new CommandFilter(new LinearFilter(mask, denominator, absolute), &m_image, tr("線形フィルタ"));
		m_stack->push(cmd);
	}
	updateImageLabel();
}
Exemplo n.º 13
0
void ImageWidget::filterTo1Bit()
{
	To1BitDialog dialog(this);
	if (dialog.exec() == dialog.Accepted) {
		const int threshold = dialog.getThreshold();
		IImageFilter *filter = NULL;
		switch (dialog.getWayTo1Bit()) {
		case To1BitDialog::WayThresholdMethod:
			filter = new FilterTwoLebelByThreshold(threshold);
			break;
		case To1BitDialog::WayErrorDiffusionMethod:
			filter = new FilterTwoLebelByErrorDiffusion();
			break;
		default:
			QMessageBox::warning(this, tr("Error"), tr("No good."));
			return;
		}
		CommandFilter *cmd = new CommandFilter(filter, &m_image, tr("2値化"));
		m_stack->push(cmd);
	}
	updateImageLabel();
}
Exemplo n.º 14
0
void ImageWidget::medianFilter()
{
	CommandFilter *cmd = new CommandFilter(new MedianFilter(3), &m_image, tr("メディアンフィルタ"));
	m_stack->push(cmd);
	updateImageLabel();
}
Exemplo n.º 15
0
void MainWindow::OpenImage()
{
	mCurrentImage->load(QFileDialog::getOpenFileName(this, tr("Open Image"), "", tr("Image Files (*.jpg)")));
	updateImageLabel(mCurrentImage, mImageLabel, 0, 0);
}
Exemplo n.º 16
0
void ImageWidget::paste(const QImage &image) {
	CommandImageChange *cmd = new CommandImageChange(this, &m_image, image, tr("貼り付け"));
	m_stack->push(cmd);
	updateImageLabel();
	autoImageResize();
}
Exemplo n.º 17
0
void ImageWidget::filterGrayscale()
{
	CommandFilter *cmd = new CommandFilter(new FilterGrayscale(), &m_image, tr("グレースケール化"));
	m_stack->push(cmd);
	updateImageLabel();
}