No License

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

» Watch video

Highlights from
Contour Tracing & Line Following

2.6 | 5 ratings Rate this file 19 Downloads (last 30 days) File Size: 3.98 KB File ID: #4497 Version: 1.0
image thumbnail

Contour Tracing & Line Following


Anoop Sadani (view profile)


18 Feb 2004 (Updated )

Contour tracing in a binary image given a point on the contour.

| Watch this File

File Information

Contour Tracing of a Black White Image (Binary Image).

Save this file in the MATLAB/Work folder and on the MATLAB Command Prompt type "help contour_trace"
   Assuming Foreground to be in Black and Background to be in White, this function traces the entire contour and requires row and column value of any pixel which lies on the contour and returns the (row,column) values of all the points which lie on the contour.
This can be used in Line Following Algorithms also.
Syntax :
    Input :
    r,c - row, column value of a single pixel on the contour.
    BW - Black & White Image (Binary Image).
    Output :
    I - Binary Image containing just the desired contour.
    pixel - N x 2 matrix which stores the pixel value of the contour, column1 gives the rows & column2 the corresponding column.

Required Products Image Acquisition Toolbox
Image Processing Toolbox
MATLAB release MATLAB 6.5 (R13)
Other requirements Algorithm may have some memory constraints
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (8)
19 May 2016 María Victoria García

How can I use this algorithm as line follower? I don't know how I must edit it to get a line follower robot.


Comment only
02 Mar 2012 mohamed

how can i merge between Image Acquisition Toolbox and line tracing ???

Comment only
22 Oct 2009 kikac4 Chawla

i downloaded your function, contour_trace from the matlab central website. i am attempting to run it and am getting the following error message:

??? Attempted to access BW(49,745); index out of bounds because size(BW)=[165,744].

do you have any ideas on how to fix this error? BW is a binary image

14 Sep 2007 Tony Yin

Doesn't work :(

Comment only
01 Feb 2006 another contour_trace User

It doesn't work in most of cases.

10 Nov 2004 Yuan Luo

it may work in tracing a one-pixel binary curvature, but not work in finding contour of large closed area

26 Mar 2004 Stijn Helsen

With a test, it didn't work well. The contour points were found, but not in the right order (many quick jumps between two parts of the contour appeared).

25 Feb 2004 contour_trace User

Very helpful for tracing the entire contour if one of the point on the contur is know. Can be used in contour segmentation - if one point on the contour is known/detected

Contact us