1 /************************************************************************************
\r
4 * This program is demonstration for functions cvFloodFill() and cvFloodFill8()
\r
7 * Trackbar specify maximal difference of the values of appurtenant to
\r
8 * repainted area pixel and one of its neighbors.
\r
10 * Autor: Denis Burenkov
\r
13 ************************************************************************************/
\r
15 char file_name[] = "EXPO0002.bmp";
\r
17 char wndname01[] = "Source image";
\r
18 char wndname02[] = "Result image for cvFloodFill";
\r
19 char wndname03[] = "Result image for cvFloodFill8";
\r
20 char barname01[] = "Maximal difference";
\r
21 int slider_pos[1] = {5};
\r
24 CvConnectedComp comp;
\r
27 // Load the source image. HighGUI use.
\r
28 IPLIMAGE image01 = load_iplimage( file_name );
\r
32 printf("File '%s' not found.\n", file_name);
\r
37 // Create the destination images. HighGUI use.
\r
38 IPLIMAGE image02 = cvCreateImage( cvSize(image01->width,image01->height),
\r
42 IPLIMAGE image03 = cvCreateImage( cvSize(image01->width,image01->height),
\r
47 // Make onechannel image. IPL use.
\r
48 cvCvtColor(image01,image02,CV_BGR2GRAY);
\r
51 // Create windows. HighGUI use.
\r
52 named_window( wndname01, 0 );
\r
53 named_window( wndname02, 0 );
\r
57 // Specify coordinates of the seed point inside the image ROI.
\r
62 // Define trackbar callback functons. This function make a
\r
63 // flood filling of connected area of the image.
\r
64 void on_trackbar_FloodFill( int h )
\r
67 cvCopyImage(image02 , image03);
\r
70 cvFloodFill( image03, seed, 0, slider_pos[0], slider_pos[0], &comp,4);
\r
72 // Show the result image. HighGUI use.
\r
73 show_iplimage( wndname02, image03 );
\r
80 // Create toolbars. HighGUI use.
\r
81 create_trackbar( barname01, wndname02, &slider_pos[0], 30, on_trackbar_FloodFill );
\r
85 on_trackbar_FloodFill(0);
\r
89 // Show the source image. HighGUI use.
\r
90 show_iplimage( wndname01, image02 );
\r
93 // Wait for a key stroke; the same function arranges events processing
\r
95 cvReleaseImage(&image01);
\r
96 cvReleaseImage(&image02);
\r
97 cvReleaseImage(&image03);
\r
100 destroy_window(wndname01);
\r
101 destroy_window(wndname02);
\r