canny algorithm, part one
DESCRIPTION
So, the main difference between Canny Part One and Sobel is t he smoothener (Canny uses a Gaussian Sobel uses the four one’s. To write code for canny, we will start with marrh.c and do these steps. -- Marrh.c uses flexible size masks (which we need), we will keep - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Canny Algorithm, Part One](https://reader036.vdocuments.us/reader036/viewer/2022081507/56815b47550346895dc924b7/html5/thumbnails/1.jpg)
• Canny Algorithm, Part One
So, the main difference between Canny Part One and Sobel isthe smoothener (Canny uses a Gaussian Sobel uses the four one’s.
To write code for canny, we will start with marrh.c and do these steps. -- Marrh.c uses flexible size masks (which we need), we will keep this part of the code. -- Marrh.c uses second derivatives, whereas we need only first derivatives (we need first x- and y- derivatives), so we will change the equation in the marrh.c line to be the first x-derivative. -- Then, because we need two derivatives, we will double up on that line, i.e., make a copy of it to compute the y-derivative, finally ending up with two masks (xmask and ymask).
![Page 2: Canny Algorithm, Part One](https://reader036.vdocuments.us/reader036/viewer/2022081507/56815b47550346895dc924b7/html5/thumbnails/2.jpg)
• Canny Algorithm, Part One
-- Then use the convolution code from marrh but remember to double up on it, to get two outputs. -- Then delete the code in marrh that is below the convolution code. -- Then bring in the sqrt (of squares) code from sobel. This will compute the magnitude, will scale it for output, and will print it out.
-- At this point, you are done with Canny part One, and your code should produce output very similar to the Sobel magnitude image.
![Page 3: Canny Algorithm, Part One](https://reader036.vdocuments.us/reader036/viewer/2022081507/56815b47550346895dc924b7/html5/thumbnails/3.jpg)
Canny Part Two
Also called Non-maximaSuppression
![Page 4: Canny Algorithm, Part One](https://reader036.vdocuments.us/reader036/viewer/2022081507/56815b47550346895dc924b7/html5/thumbnails/4.jpg)
![Page 5: Canny Algorithm, Part One](https://reader036.vdocuments.us/reader036/viewer/2022081507/56815b47550346895dc924b7/html5/thumbnails/5.jpg)
![Page 6: Canny Algorithm, Part One](https://reader036.vdocuments.us/reader036/viewer/2022081507/56815b47550346895dc924b7/html5/thumbnails/6.jpg)
![Page 7: Canny Algorithm, Part One](https://reader036.vdocuments.us/reader036/viewer/2022081507/56815b47550346895dc924b7/html5/thumbnails/7.jpg)
![Page 8: Canny Algorithm, Part One](https://reader036.vdocuments.us/reader036/viewer/2022081507/56815b47550346895dc924b7/html5/thumbnails/8.jpg)
![Page 9: Canny Algorithm, Part One](https://reader036.vdocuments.us/reader036/viewer/2022081507/56815b47550346895dc924b7/html5/thumbnails/9.jpg)
![Page 10: Canny Algorithm, Part One](https://reader036.vdocuments.us/reader036/viewer/2022081507/56815b47550346895dc924b7/html5/thumbnails/10.jpg)
![Page 11: Canny Algorithm, Part One](https://reader036.vdocuments.us/reader036/viewer/2022081507/56815b47550346895dc924b7/html5/thumbnails/11.jpg)
![Page 12: Canny Algorithm, Part One](https://reader036.vdocuments.us/reader036/viewer/2022081507/56815b47550346895dc924b7/html5/thumbnails/12.jpg)
![Page 13: Canny Algorithm, Part One](https://reader036.vdocuments.us/reader036/viewer/2022081507/56815b47550346895dc924b7/html5/thumbnails/13.jpg)
![Page 14: Canny Algorithm, Part One](https://reader036.vdocuments.us/reader036/viewer/2022081507/56815b47550346895dc924b7/html5/thumbnails/14.jpg)
![Page 15: Canny Algorithm, Part One](https://reader036.vdocuments.us/reader036/viewer/2022081507/56815b47550346895dc924b7/html5/thumbnails/15.jpg)
![Page 16: Canny Algorithm, Part One](https://reader036.vdocuments.us/reader036/viewer/2022081507/56815b47550346895dc924b7/html5/thumbnails/16.jpg)
![Page 17: Canny Algorithm, Part One](https://reader036.vdocuments.us/reader036/viewer/2022081507/56815b47550346895dc924b7/html5/thumbnails/17.jpg)
![Page 18: Canny Algorithm, Part One](https://reader036.vdocuments.us/reader036/viewer/2022081507/56815b47550346895dc924b7/html5/thumbnails/18.jpg)
![Page 19: Canny Algorithm, Part One](https://reader036.vdocuments.us/reader036/viewer/2022081507/56815b47550346895dc924b7/html5/thumbnails/19.jpg)
![Page 20: Canny Algorithm, Part One](https://reader036.vdocuments.us/reader036/viewer/2022081507/56815b47550346895dc924b7/html5/thumbnails/20.jpg)
Actual code for Peaks• for(i=MR;i<256-MR;i++){• for(j=MR;j<256-MR;j++){•
• if((xconv[i][j]) == 0.0) {• xconv[i][j] = .00001;• }• slope = yconv[i][j]/xconv[i][j];• if( (slope <= .4142)&&(slope > -.4142)){• if((mag[i][j] > mag[i][j-1])&&(mag[i][j] > mag[i][j+1])){• cand[i][j] = 255;• }• }• else if( (slope <= 2.4142)&&(slope > .4142)){• if((mag[i][j] > mag[i-1][j-1])&&(mag[i][j] > mag[i+1][j+1])){• cand[i][j] = 255;• }• }• else if( (slope <= -.4142)&&(slope > -2.4142)){• if((mag[i][j] > mag[i+1][j-1])&&(mag[i][j] > mag[i-1][j+1])){• cand[i][j] = 255;• }• }else{• if((mag[i][j] > mag[i-1][j])&&(mag[i][j] > mag[i+1][j])){• cand[i][j] = 255;• }• }• }• }
![Page 21: Canny Algorithm, Part One](https://reader036.vdocuments.us/reader036/viewer/2022081507/56815b47550346895dc924b7/html5/thumbnails/21.jpg)
Hysteresis (Double) Threshold