-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreprocessingblock.cpp
More file actions
157 lines (119 loc) · 3.83 KB
/
Copy pathpreprocessingblock.cpp
File metadata and controls
157 lines (119 loc) · 3.83 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#include "preprocessingblock.h"
#include "ui_preprocessingblock.h"
#include "myheader.h"
#include "QMessageBox"
#include "undopreprocessing.h"
PreProcessingBlock::PreProcessingBlock(QWidget *parent) :
QDialog(parent),
ui(new Ui::PreProcessingBlock)
{
ui->setupUi(this);
}
PreProcessingBlock::~PreProcessingBlock()
{
delete ui;
}
IITkgp_functions::folder folderobj;
Mat PreProcessedImage;
void PreProcessingBlock::on_pushButton_clicked() // select (morphological operation)
{
this->setEnabled(false);
int MorphologicalOperation;
if(ui->radioButton->isChecked())
{
QMessageBox::information(0,"Morphological Operation","Erosion is selected");
MorphologicalOperation = 0;
}
if(ui->radioButton_2->isChecked())
{
QMessageBox::information(0,"Morphological Operation","Dilation is selected");
MorphologicalOperation = 1;
}
if(ui->radioButton_3->isChecked())
{
QMessageBox::information(0,"Morphological Operation","Open is selected");
MorphologicalOperation = 2;
}
if(ui->radioButton_4->isChecked())
{
QMessageBox::information(0,"Morphological Operation","Close is selected");
MorphologicalOperation = 3;
}
ResultImage.copyTo(PreProcessedImage);
IITkgp_functions::Morphology MorOp;
ResultImage = MorOp.Morphology_Gui(PreProcessedImage,MorphologicalOperation);
namedWindow("Preprocessed Image",CV_WINDOW_KEEPRATIO);
imshow("Preprocessed Image",ResultImage);
waitKey(0);
this->setEnabled(true);
}
void PreProcessingBlock::on_pushButton_2_clicked() // Done
{
destroyWindow("Preprocessed Image");
/*
char *name;
name = (char *) malloc ( 2001 * sizeof(char));
if(name == NULL)
{
printf("Memory can not be allocated\n");
exit(0);
}
name = folderobj.CreateNameIntoFolder(substring,"PreProcessedImage.png");
imwrite(name,ResultImage);
*/
ResultImage.copyTo(PreProcessedImage);
Mat drawing;
IITkgp_functions::ProcessingBlocks PB;
drawing = PB.FindProcessingBlocks(PreProcessedImage);
namedWindow("Processing Blocks",CV_WINDOW_KEEPRATIO);
imshow("Processing Blocks",drawing);
//waitKey(0);
this->close();
UndoPreprocessing UPP;
UPP.setModal(true);
UPP.exec();
}
void PreProcessingBlock::on_pushButton_3_clicked() // Boundary extraction
{
this->setEnabled(false);
IITkgp_functions::Morphology MorOp;
PreProcessedImage = MorOp.boundaryextraction(ResultImage);
PreProcessedImage.copyTo(ResultImage);
PreProcessedImage.release();
char *name;
name = (char *) malloc ( 2001 * sizeof(char));
if(name == NULL)
{
printf("Memory can not be allocated\n");
exit(0);
}
name = folderobj.CreateNameIntoFolder(substring,"PreProcessedImage.png");
imwrite(name,ResultImage);
namedWindow("Preprocessed Image",CV_WINDOW_KEEPRATIO);
imshow("Preprocessed Image",ResultImage);
waitKey(0);
this->setEnabled(true);
}
void PreProcessingBlock::on_pushButton_4_clicked() // select (smoothing or gapfilling)
{
this->setEnabled(false);
int sgtype;
//int direction;
if(ui->radioButton_5->isChecked()) // smoothing
{
QMessageBox::information(0,"Preprocessing Technique","Smoothing is selected");
sgtype = 0;
}
if(ui->radioButton_6->isChecked()) // gapfilling
{
QMessageBox::information(0,"Preprocessing Technique","Gapfilling is selected");
sgtype = 1;
}
IITkgp_functions::SmoothingGapfilling SGO;
ResultImage.copyTo(PreProcessedImage);
ResultImage = SGO.smoothinggapfilling_GUI(PreProcessedImage,sgtype);
namedWindow("Preprocessed Image",CV_WINDOW_KEEPRATIO);
imshow("Preprocessed Image",ResultImage);
waitKey(0);
this->setEnabled(true);
}