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.
It's not clear what this code does that the function bwboundaries(), in the Image Processing Toolbox, already does. Can you explain the differences, if any?
Great job Francois,
But i have still a problem with this code. The code moves the orientation of the object to find coordinates (as we can see in your picture to introduce your code).
In my case is very important to keep the initial object in the same axis system. To be more clear i want to record with a fixed camera several binary images of an object which will be a little perturbated. So if i want to compare the perturbated object with a non-perturbated one, i need to keep the same axis system (for exemple, the entire image).
I hope have been enough clear about my problem.
Thx again for your sharing.
Thanks for your sharing.
Can this be used for Video,, If yes please let me know , thanks in advance
Robust and easy to use.
my intention was to get the contour of only one object. In your application you sometime have two objects. If you get at least one pixel of one of the objects you can remove it easily (look after geodesic reconstruction in mathematical morphology). Once this is done you can repeat the process for each other object.
Hi Francois Mourougaya,
How r u?
Your code is good but it contains a little bit problem. If the image is broken it doesnot show all the contours. Let us consider the image of bone fracture. If its broken from middle then it will show contour of only one part and the contour of the other part doesnot show. If you resolve this problem them its the best program I have ever seen
Nice program and faster than I expected. If dealing with only a BW image, you can get the edges faster than bwmorph and imerode which can be very slow for large images. Use an averaging filter and filter out its results.
Hello everyone, I'm the author of this file, and I see there were already some downloads, but no rating or comment.
If you download it, can you please give feedback, to know if you found it usefull or if you think its total crap (in this case, please tell me what's wrong so I can improve it !).
Thanks anyway for you interest,