No License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

4.2 | 8 ratings Rate this file 19 Downloads (last 30 days) File Size: 3.76 KB File ID: #14947 Version: 1.0
image thumbnail




10 May 2007 (Updated )

CONTOUR_FOLLOWING takes a B&W image, returns the sorted contour points.

| Watch this File

File Information

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.

Required Products Image Processing Toolbox
MATLAB release MATLAB 7 (R14)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (11)
17 Nov 2013 Wei Teck

13 Mar 2013 Image Analyst

Image Analyst (view profile)

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?

Comment only
11 Mar 2012 eunn

eunn (view profile)

nice one!~

05 Feb 2010 Anthony Delmas

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.

21 Nov 2009 Raymond Cheng

Thanks for your sharing.

31 Mar 2008 priyanka desai

Can this be used for Video,, If yes please let me know , thanks in advance

28 Mar 2008 Andrea Morgera

Robust and easy to use.

30 Sep 2007 Fran├žois Mourougaya

Dear Bashir,
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.

Comment only
14 Sep 2007 Bashir Ayesha

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

13 Jul 2007 Amit Shesh

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.

09 Jul 2007 Fran?ois Mourougaya

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,

Comment only

Contact us