C = CONTOUR_FOLLOWING(BW) takes BW as an input. BW is a binary array containing the image of an object ('1': foreground, '0': background). It returns a circular list (N x 2, C(1,:)=C(end,:)) of the (row,column)-coordinates of the object's contour, in the order of appearance (This function was inspired from the freeman contour coding algorithm).
- if the object is less than 3 pixels, CONTOUR_FOLLOWING sends back [0 0].
- the algorithm is quite robust: the object can have holes, and can also be only one pixel thick in some parts (in this case, some coordinates pair will appear two times: they are counted "way and back").
This function was originally developed in order obtain an initialization for a snake algorithm.
The .zip files contains some example images and a test script.