CSC 370

CSC 370 Assignment: Segmentation

 

This assignment looks at several segmentation algorithms in a comparative manner. One algorithm is color-based segmentation using k-means, as described in this Matlab demo. Another is from the segmentation paper by Felzenszwalb and Huttenlocher. If you will be completing this on your own computer, you may need to download a compiled mex binary (Mac, Windows). Put these in your Matlab working directory, or somewhere else on the Matlab path.

Felzenszwalb/Huttenlocher Segmentation

The function that performs the segmentation is called segment. It takes up to three arguments: the image to be segmented (which may be either color or grayscale), a scale parameter, and a minimum segment size. The scale parameter controls the grouping behavior of the algorithm, as described when the paper was presented. A large value tends to yield larger segments. The third argument suppresses very small segments (below the specified size). Any segments below this threshold in size are merged into the most similar neighboring segment. In addition to the label image of the segmentation, the function also returns the number of segments as an optional second value.

To segment an image, first smooth it slightly using a small Gaussian mask. (This step is important, because without it the segment routine can take much longer to compute.) Then pick parameter values and segment. You can display your result using imagesc (which will show each segment in a different shade or color) or showseg, which will superimpose white lines on the original image.

>> img = imread('loco.jpg');
>> img = double(img)/255;
>> img = convn(img,[1 2 1; 2 4 2; 1 2 1]/16,'same');
>> [seg,nseg] = segment(img,4000,100);
>> nseg
nseg =
   105
>> imagesc(seg)
>> showseg(img,seg);

To Do

Before proceeding further, look at each of the images listed at the bottom of this lab, and decide what you think a proper segmentation would be. Sketch this out on a piece of paper. Now segment each automatically using the two methods above, choosing and reporting the parameter values for each image that you feel give the best segmentation. Show your Matlab code and the result using showseg (you may have to enlarge the image to see all the detail). Then answer the questions below.

  1. How closely do the computer's segmentations match the segmentations you would have created if you had been doing this yourself?
  2. Which algorithm produces the best segmentation? Does it vary depending on the image?
  3. What would you say is the greatest weakness of the automatic segmentations (i.e., in what way do they diverge most from your intended answer?
  4. How much do your parameter values vary from image to image? Do you think it would be possible to choose one general set of parameters that would apply to every image? What does this say about fully automatic segmentation as a goal?

Finally, identify several other images (at least three) that you think would be interesting to segment, and repeat your investigations using them.

Images

Locomotive
Peppers
St. Basil's
Wrenches