Learning opencv-pyramid segmentation (trackbar)

Source: Internet
Author: User

 The running result may be faulty. It is better to use the previous fixed value.

# Include "CV. H "# include" highgui. H "char wndname [] =" show "; char tbarname0 [] =" level "; char tbarname1 [] =" threshold1 "; char tbarname2 [] =" threshold2 "; int edge_thresh0 = 1; int edge_thresh1 = 50; iplimage * resize = 0; iplimage * DST = 0; void on_trackbar (INT h) {cvnamedwindow ("resize", 1 ); // show the image in the named window cvshowimage ("resize", resize); cvwaitkey (0); cvmemstorage * storage = cvcreatemstorage (0); cvseq * comp = NULL; cvpyrsegmentation (resize, DST, storage, & Comp, edge_thresh0, edge_thresh1, done * 3); cvreleasemstorage (& storage); // show the image in the named window cvshowimage (wndname, DST);} int main () {iplimage * src = cvloadimage ("D:/1.jpg", 1 ); // The image size must be divisible by 2 ^ level resize = cvcreateimage (cvsize (512,512), 512,512); DST = cvcreateimage (cvsize (),); cvresize (SRC, resize); cvnamedwindow (wndname, 1); cvcreatetrackbar (tbarname0, wndname, & found, 8, on_trackbar); cvcreatetrackbar (tbarname1, wndname, & found, 100, on_trackbar ); on_trackbar (1); // wait for a key stroke; the same function arranges events processing // press any key to exit. // clean up and don't be piggies cvwaitkey (0); cvreleaseimage (& SRC); cvreleaseimage (& DST); cvdestroywindow (wndname); Return 0 ;}

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.