//mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QFileDialog>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <vector>
#include <QtCore/QCoreApplication>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/types_c.h>
#include <opencv2/imgproc/imgproc.hpp>
namespace Ui {
class MainWindow;
}
{
Q_OBJECT
public:
explicit MainWindow
(QWidget *parent
= 0);
~MainWindow();
private slots:
void on_pushButton_clicked();
void on_pushButton_2_clicked();
void on_pushButton_3_clicked();
private:
Ui::MainWindow *ui;
//Images variables
cv::Mat image_Idl;
cv::Mat image_Lit;
cv::Mat image_Idl_G;
cv::Mat image_Lit_G;
double threshHold;
};
#endif // MAINWINDOW_H
//mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QFileDialog>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <vector>
#include <QtCore/QCoreApplication>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/types_c.h>
#include <opencv2/imgproc/imgproc.hpp>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void on_pushButton_clicked();
void on_pushButton_2_clicked();
void on_pushButton_3_clicked();
private:
Ui::MainWindow *ui;
//Images variables
cv::Mat image_Idl;
cv::Mat image_Lit;
cv::Mat image_Idl_G;
cv::Mat image_Lit_G;
double threshHold;
};
#endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode
//mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <iostream>
#include <QtCore/QCoreApplication>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/types_c.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <QSpinBox>
#include <QSlider>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->horizontalSlider->setRange(0,255);
ui->spinBox->setRange(0,255);
connect(ui->horizontalSlider,SIGNAL(valueChanged(int)),ui->spinBox,SLOT(setValue(int)));
connect(ui->spinBox,SIGNAL(valueChanged(int)),ui->horizontalSlider,SLOT(setValue(int)));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
QString fileName
= QFileDialog::getOpenFileName(this,tr
("Load Lit Image"),
".",tr
("Image Files (*.png *.jpg *.jpeg *.bmp)"));
image_Lit = cv::imread(fileName.toAscii().data());
cv::namedWindow("Lit Image");
cv::imshow("Lit Image", image_Lit);
}
void MainWindow::on_pushButton_2_clicked()
{
QString fileName
= QFileDialog::getOpenFileName(this,tr
("Load Lit Image"),
".",tr
("Image Files (*.png *.jpg *.jpeg *.bmp)"));
image_Idl = cv::imread(fileName.toAscii().data());
cv::namedWindow("Ideal Lit");
cv::imshow("Ideal Lit", image_Idl);
}
void MainWindow::on_pushButton_3_clicked()
{
//Converstions
//Convert Lit to gray
cv::cvtColor(image_Lit, image_Lit_G,CV_RGB2GRAY);
//Convert Ideal gray
cv::cvtColor(image_Idl, image_Idl_G,CV_RGB2GRAY);
//Threshold the Images to a designated value
// Lit
threshHold = ui->horizontalSlider->value();
cv::threshold(image_Lit_G,image_Lit_G, threshHold,255,cv::THRESH_BINARY);
cv::namedWindow("Gray Scaled Image");
cv::imshow("Gray Scaled Image", image_Lit_G);
}
//mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <iostream>
#include <QtCore/QCoreApplication>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/types_c.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <QSpinBox>
#include <QSlider>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->horizontalSlider->setRange(0,255);
ui->spinBox->setRange(0,255);
connect(ui->horizontalSlider,SIGNAL(valueChanged(int)),ui->spinBox,SLOT(setValue(int)));
connect(ui->spinBox,SIGNAL(valueChanged(int)),ui->horizontalSlider,SLOT(setValue(int)));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this,tr("Load Lit Image"),".",tr("Image Files (*.png *.jpg *.jpeg *.bmp)"));
image_Lit = cv::imread(fileName.toAscii().data());
cv::namedWindow("Lit Image");
cv::imshow("Lit Image", image_Lit);
}
void MainWindow::on_pushButton_2_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this,tr("Load Lit Image"),".",tr("Image Files (*.png *.jpg *.jpeg *.bmp)"));
image_Idl = cv::imread(fileName.toAscii().data());
cv::namedWindow("Ideal Lit");
cv::imshow("Ideal Lit", image_Idl);
}
void MainWindow::on_pushButton_3_clicked()
{
//Converstions
//Convert Lit to gray
cv::cvtColor(image_Lit, image_Lit_G,CV_RGB2GRAY);
//Convert Ideal gray
cv::cvtColor(image_Idl, image_Idl_G,CV_RGB2GRAY);
//Threshold the Images to a designated value
// Lit
threshHold = ui->horizontalSlider->value();
cv::threshold(image_Lit_G,image_Lit_G, threshHold,255,cv::THRESH_BINARY);
cv::namedWindow("Gray Scaled Image");
cv::imshow("Gray Scaled Image", image_Lit_G);
}
To copy to clipboard, switch view to plain text mode
Bookmarks