The format of the Canny operator is as follows:
Canny
Edge Detection Using the Canny algorithm
void cvCanny( const CvArr* image, CvArr* edges, double threshold1, double threshold2, int aperture_size=3 );
-
Image
-
Single-channel input image.
-
Edges
-
Output image of single-channel storage edge
-
Threshold1
-
First Threshold
-
Threshold2
-
Second threshold
-
Aperture_size
-
Sobel operator kernel size (see cvsobel ).
The cvkan function uses the "quick" algorithm to detect the edge of the input image and identify the edge in the output image. The small threshold values in threshold1 and threshold2 are used to control edge connections, and the large threshold value is used to control the initial segmentation of strong edges.
- Note: cvkan only accepts single-channel images as input.
- External link: for the implementation of a typical opencv algorithm based on the self-tuning threshold of the canny threshold, see automatically determining the segmentation threshold of the moderation Algorithm in opencv.
Implementation example:
# Include "stdafx. H "# include" CV. H "# include" cxcore. H "# include" highgui. H "int main (INT argc, char ** argv) {// declare iplimage pointer iplimage * IMG = NULL; iplimage * cannyimg = NULL; char * filename; filename = "lena.png"; IMG = cvloadimage (filename, 1); // load the image and forcibly convert it to grayif (IMG = cvloadimage (filename, 0 ))! = 0) {// apply for the cannyimg = cvcreateimage (cvgetsize (IMG), ipl_depth_8u, 1) for the cell-edge image of the state-of-the-art cloud. // The value of the value can be 50,150, 3); // create a window cvnamedwindow ("src", 1); cvnamedwindow ("kan", 1); // display the image cvshowimage ("src", IMG ); cvshowimage ("kan", cannyimg); cvwaitkey (0); // wait for a button // destroy the cvdestroywindow ("src"); cvdestroywindow ("kan "); // release the image cvreleaseimage (& IMG); cvreleaseimage (& cannyimg); Return 0 ;}return-1 ;}
The running result is:
References:
1. Learning opencv, Yu Shiqi, Liu Rui, Tsinghua University Press, pp.173-175
2. http://www.opencv.org.cn/index.php/Cv%E5%9B%BE%E5%83%8F%E5%A4%84%E7%90%86#Canny
3. http://bkxcnm.blog.163.com/blog/static/110537965200932310555777/