File Exchange

image thumbnail


version (3.15 KB) by Dirk-Jan Kroon
Find ISO-contour geometry in a 2D image using marching-squares, and sort the contour objects


Updated 10 Mar 2011

View Version History

View License

This function ISOCONTOUR computes the isocontour geometry for a certain 2D image and isovalue. To Extract the isocontour geometry it uses Marching Squares and linear interpolation. Followed by sorting the contour geometry into separate contour-objects.

This function is the 2D equivalent of Isosurface extraction using Marching Cubes in 3D.

I : An 2D image (grey-scale)
isovalue : The Iso-value of the contour

Lines : An array describing all the Line-pieces of the isocontour
geomtery, with a N x 2 index list of vertices
Vertices : Vertices (Corners) of the lines M x 2 list of X,Y
Objects : A 1 x K cell array with in every cell a list of indices
corresponding to one connect isocontour. If the isocontour
is closed then the last index value is equal to first index

Cite As

Dirk-Jan Kroon (2021). Isocontour (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (12)

Honglin Chen

Christian Ragg

Qingmeng Wen

Jack Chen

Hello,what do you mean by saying "base-edges"?

Chris Loizou

Can you add the paper with I have to cite when I use this method. Thank you very much

Zeyu Wang

Very useful! I cannot find the paper to cite, so I put you into acknowledgment. Cheers.

Hiroyuki Goto

Very useful and easy to use!
But I think the last segment (point) lacks if a contour is open. Should lines 121 and 123-125 be commented out?


Could you please explain to me the aim of the two function implemented in the isocontour function.
For exemple matrices I, E, IE. What are representing?

Tushar Athawale

I am trying to compute line and vertices for a 2x2 cell. It is throwing an error.
Can somebody tell me how to do it?

Reja Rabbi

Is it possible to compute the area above a gray scale value?

Ken Campbell

Could you give an example of how to extract the indices for the pixels that a given contour passes through? I have been struggling to get this to work myself. Thank you for submitting this to the FileExchange.

Bas Boom

Can you add the paper with I have to cite when I use this method. Nice method by the way, already might have solved two problems with it. Cheers Bas

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!