-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmainwindow.cpp
127 lines (87 loc) · 2.82 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "medianfilter.h"
#include "sobelfilter.h"
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <QFileDialog>
using namespace cv;
using namespace std;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{ // Re
ui->setupUi(this);
ui->completa->setVisible(false);
ui->filtro_medianas->setVisible(false);
cv::Mat inputImage = cv::imread("D:marilin.jpg",CV_LOAD_IMAGE_GRAYSCALE);
if(! inputImage.data ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
}else {
namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Display window", inputImage );
}
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pathimg_textChanged()
{
}
void MainWindow::on_OpenImg_clicked(){
}
void MainWindow::printMat(Mat mat){
namedWindow( "Imprimiendo imagen", WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Display window", mat);
}
void MainWindow::on_addfile_clicked()
{
QString imgpath=QFileDialog::getOpenFileName();
ui->imgpath->setText(imgpath);
if (imgpath==""){
cout<<"emptyfile"<<endl;
}else {
cv::Mat inputImage = cv::imread(imgpath.toStdString(),CV_LOAD_IMAGE_GRAYSCALE);
this->image=inputImage;
// inputImage.convertTo(inputImage, CV_32F, 1.0/255);
//SVD svdimagencita(inputImage);
cv::Size size(300,300);//the dst image size,e.g.100x100
cv::Mat temp;
cv::resize(inputImage,temp,size);//resize image
//el resto de la prueba
// Qt image
QImage img= QImage((const unsigned char*)(temp.data),
temp.cols,temp.rows,QImage::Format_Indexed8);
// display on label
ui->img_2->setPixmap(QPixmap::fromImage(img));
// resize the label to fit the image
ui->img_2->resize(ui->img_2->pixmap()->size());
ui->completa->setVisible(true);
ui->filtro_medianas->setVisible(true);
img.save("mico");
imwrite( "micoopensv.jpg", image );
}
}
void MainWindow::on_img_2_linkActivated(const QString &link)
{
}
void MainWindow::on_completa_clicked()
{
printMat(this->image);
}
void MainWindow::on_filtro_medianas_clicked()
{
MedianFilter *medianfilter = new MedianFilter();
medianfilter->DisplayImageFiltrada(image.clone());
medianfilter->show();
}
void MainWindow::on_filtro_sobel_clicked(){
SobelFilter *sobelfilter = new SobelFilter();
sobelfilter->DisplayImageFiltrada(image.clone());
sobelfilter->show();
}