-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathotsuThresholdingMain.cpp
executable file
·40 lines (29 loc) · 1.04 KB
/
otsuThresholdingMain.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
#include "showImage.h"
#include "histogram2.h"
#include "otsuThresholding.h"
#include "imageSegmentation.h"
#include <time.h>
int main( int argc, char** argv ){
clock_t t1,t2;
t1=clock();
Mat image=loadImage(argv[1]);
showImage(image,"Original Image");
histogram before=createHist(256),after=createHist(256);
Mat imageGr=Grayscaler(image);
showImage(imageGr,"Grayscale");
fillHistogram(&before,imageGr);
waitKey(0);
statistikHistogram(before);
// double ** tessub1 = generateVariance(before,200,1);
int singleThreshold=otsuThresholding(before);
int * duoThreshold=duoOtsu(before);
std::cout << "Single Threshold\t: "<<singleThreshold << std::endl;
std::cout << "Dual Threshold\t\t: "<<duoThreshold[0]<<" , "<<duoThreshold[1] << std::endl;
showImage(singleThresholdSegmentation(imageGr,singleThreshold),"Otsu 1");
showImage(duoThresholdSegmentation(imageGr,duoThreshold),"Otsu 2");
waitKey(0); // Wait for a keystroke in the window
t2=clock();
float diff ((float)t2-(float)t1);
cout<<diff<<endl;
return 0;
}