CS 791 E Computer Vision

Programming Assigment  #2


Problem 2:  Snake approach


1. The program


                      -----------Welcome to Beifang's 'Snaking' program!!--------
                       This program interacts with you via key and mouse and terminal.
                      ----------------------------------------------------------
                     FIRST: CLICK ON THE IMAGE/INTERFACE and then....
                     type 'P' or 'p'-----to click the snake INITIAL points.
                     type 'Q' or 'q'-----to be OUT of getting initial points.
                    type 'W' or 'w'-----to save into file those initial points.
                    type 'R' or 'r'-----to read from a file the initial points.
                    type 'S' or 's'-----to save the image with the snake trace.
                    type 'A' or 'a'-----to save the image for use of animated GIFs.
                    type 'V' or 'v'-----to go to A DETAILED Snaking Progress
                    type 'U' or 'u'-----to be out of the above 'V'/'v' Process.
                    type 'D' or 'd'-----to recording the above 'V'/'v' Process.
                    type  SPACEBAR -----to quit this program.
                     -------Click/Move the alpha/beta/gamma sliderbar to do snaking-----
                   -----------------------------------------------------------
                  ALWAYS MAKE the image/interface the current environment.
                 Images saved in file format:
                           s_alphaX100_betaX100_gammaX100_maskSize.jpg
                          a_nnn.jpg
                          d_nnn.jpg


 

fig. 2.1.  The GUI for deformable contour testing.



2. Results


    I put the results for all the testing images here.  To show the resulting effect I combined the testing image, some (small part ) of the intermediate images (sampled during the snaking process), and the final result image into  animated GIFs: all boundaries changing accordingly.  From these animated images we will start the analysis and discussion in the following section. In following  examples, I assumed the gradient flag as 1 unless otherwise indicated.



fig.  2.2.  Contour contracting for model1.pgm





fig. 2.2.  Contour contracting for geor.0004.pgm.






fig. 2.3.  Contour contracting for geor.0063.pgm






fig. 2.4.  Contour contracting for square.pgm





fig. 2.5.  Contour contracting for square_noise.pgm



 

3. Analysis and discussion


First of all, theoretically, to get a very good (a perfect) contour of an object, the initial boundary points should be obtained from the even distributed points along the initial boundary. And each point should be assigned a pair of (alpha, beta, gamma) of its own, and these values can be modified during the contour contracting process.  I have  NOT done in either because I can not afford in time. Even so, the results are good enough to deserve "analysis" and "discussion".

1. Sensitivity to the initial contour points:  the following two images are produced with exact same parameters as the fig. 2.2. except only one: the left with the same intial points as that in fig. 2.2. but the right one with the initial contour points in modelB.dat  in which the  points are more far away from the object than in the former case.   
   

fig. 2. 6. Two contours obtained with different initial contour points.



It is a reasonable result: with the same snake window size and the  apha-beta-gamma values,  if the initial points, to some degree, are out of the reach of the first hits in the snake contour contracting process, those points can NOT get closer to the object and furthermore affects the contracting thereafter, as shown in the above (fig. 2.6. ) animated image. Our question is: can we improve the "contracting" only by increasing the snake window size?  The answer is: yes, as shown in the following.

2. Sensitivity to neighborhood (snake window) size:  increasing snake window size can improve the performance of the contour contracting. The following two images are obtained with the same bad initial points as that in fig. 2.6. (and also same other parameters as in fig. 2. 2. ) but they show different results with different snake window size: left window size = 7 and right window size = 13.

   

fig. 2. 7. Improvement of contour with the increase of neighborhood size.



3. Sensitivity to alpha:  alpha forces the contour to be continuous (the elasticity) along the object contour.  The following images (fig. 2. 8.) show such effect: under the same conditions, the left image has an alph of 0.80 and the right one of alpha as 1.36. The larger the alpha, more stretched the contour along the object's true contour. This also illustrates the alpha as one of the two factors that ajust the "inner" energy of the image contour.

     
  

fig. 2. 8.  Contours with different alpha's (other parameters are same): left (0.80), right (1.36)



4. Sensitivity to beta:  beta controls the curvature (whether the  contour looks smooth or stiff). From the following images (fig. 2. 9.) we can see the effect of beta: with a larger beta in the right image (the other parameters are same), the contour tried to increase the smoothness of the whole contour.  The beta is another factor that affects the "inner" energy of the image contour, also shown in fig. 2.9.

 
fig. 2.9. Contours with different beta's (other parameters are same): left (1.31) right (2.0)



5. Sensitivity to gamma:   gamma controls the degree of the contracting of contour: it attracts the contour toward the closest image edge. In the following animated image, the contour starts from a near convex polygon far away from the object edge (in the center of the image) with gamma = 0.06 to a boundary very close to the object's true contour with gamma = 0.74 (gammas between the two are: 0.16, 0.26, 0.29, 0.35, 0.41, 0.51 and 0.61), the other parameters are the same as in fig. 2.2, that is: alpha = 0.80, beta = 0.80, and window size = 7. This animated images also display the "external" energy characteristic of gamma in the deformable contour.



fig. 2.10. Contour changing with the increase of gamma.




In all, anyone of the parameters (the snake window size, initial points, alpha, beta, and gamma) can have a certain effect on the production of contour according to their functionality in the contracting process. But it is the combination of all these parameters that determine the final effect. How to get a perfect contour for an object demands vast amount of experiments in addition to our knowledge of the parameters (just as shown in the above).