[Learning opencv Article 2] Canny edge detection

Source: Internet
Author: User

Canny edge detection


Iplimage * cvloadimage (const char * filename, int flags = cv_load_image_color );

The first parameter is the file name of the image to be loaded.

The second parameter specifies the color and depth of the image to be read,

You can convert the input image into a channel (cv_load_image_color), a single channel (cv_load_image_grayscale), or a constant (cv_load_image_anycolor ).

Void cvkan (const cvarr * image, cvarr * edges, double threshold1, double threshold2, int aperture_size = 3 );
The first parameter is image single-channel input image.
The second parameter edges stores the output image of the edge in a single channel
The third and fourth parameters are thresholds.
The last parameter is the size of the Sobel operator kernel.

# Include "stdafx. H "# include" CV. H "# include" cxcore. H "# include" highgui. H "# include <opencv. HPP> # include <iostream> using namespace STD; using namespace CV; int edge_thresh; iplimage * sourceimage, * destimage; const char * filename = "yayade.jpg "; // original image name void callback (INT); // progress bar callback function int main () {// load the image sourceimage to be processed = cvloadimage (filename, cv_load_image_anydepth | cv_load_image_anycolor ); // generate a target of the same size as the input image Image destimage = cvcreateimage (cvgetsize (sourceimage), ipl_depth_8u, 1); If (! Sourceimage) {cout <"error" <Endl; Return-1;} cvnamedwindow ("image window", cv_window_autosize); edge_thresh = 1; // only used to adjust the threshold. cvcreatetrackbar ("threshold", "image window", & edge_thresh, 100, callback); callback (0); CV: waitkey (0 ); cvreleaseimage (& sourceimage); cvreleaseimage (& destimage); cvdestroywindow ("image window"); Return 0;} void callback (INT thresh) {cvcanny (sourceimage, destimage, (float) thresh, (float) 3 * Thresh, 3); cvshowimage ("image window", destimage );}

Processing results

The first run is successful, and the second run is in this situation, but the generated EXE file can still run. I don't know what the situation is. I hope you can give me some guidance ..

Reference learning opencv


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.