Opencv learning notes-the Canny operator

Source: Internet
Author: User

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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.