-
Notifications
You must be signed in to change notification settings - Fork 1
/
EdgeDetection.cpp
49 lines (39 loc) · 1 KB
/
EdgeDetection.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
/*
Marc-Antoine Desbiens
Winter 2012
*/
#include "MImage.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
/*
Non-maximum suppression
*/
int main(int argc, char*argv[])
{
MImage img,imgGrad,imgZero,imgCanny;
if(argc<3){
printf("Error!!!\n\nNot enough parameters\nEdgeDetection.exe [image file name] [threshold] \n\n");
system("pause");
exit(1);
}
/* Load input image */
img.MLoadImage(argv[1]);
//// Gradient Magnitude Edge Detection ////////////
imgGrad = img;
imgGrad.MEdgeDetec((float) atof(argv[2]));
imgGrad.MSaveImage("outEdgeDetec.pgm",PGM_RAW);
//// Zero Crossing Edge detection ////////////
imgZero = img;
imgZero.MZeroCrossing((float) atof(argv[2]));
imgZero.MSaveImage("outZeroCrossing.pgm",PGM_RAW);
/// Canny Edge Detection //////////
imgCanny = img;
imgCanny.MNonMaxSupp();
imgCanny.MSaveImage("outNonMax.pgm",PGM_RAW);
/* Threshold */
imgCanny.MThreshold((float) atof(argv[2]));
imgCanny.MSaveImage("outNonMaxThr.pgm",PGM_RAW);
return 0;
}