File Exchange

image thumbnail

2D fast marching algorithm

version 1.3 (3.44 KB) by

computation of distance maps using fast marching



View License

Compute the distance map to a set of points using the fast marching algorithm.
Solves the 2-D eikonal PDE with constant speed T=1.
It is not very general but well suited for learning.

Comments and Ratings (8)

Shinen Lo

Great job.
Thank you.

Juan Cardelino

You can't use it directly for segmentation. This will only compute a distance map from a set of initial points. You need to read some papers and find out how to use that for segmentation.


ladi (view profile)

How can I use this program for segmentation?

Thank you

Juan Cardelino

Thank you very much for your comments. I will take them into account and try to improve the function. What you say about IPT is true, but I wrote this function many years ago without it, Im not sure if it even existed.
Thanks again.

igor scardanzan

the topic is hot
see also this contribution that works fine both in 2D and 3D

File Id: 6110 Average rating: 4.29
Size: 1345 KB # of reviews: 35
Submitted: 2004-10-24 Downloads: 5969
Subscribers: 9
Keywords: Fast Marching, level set, PDE, eikonal equation, front propagation, 3D

w s

Hi Juan,

this function provides a part of the functionality of bwdist (image processing toolbox). I think, for people that do not have the IPT this function will have some value when you do some more editing.

First, improve your help with a minimal example. E.g take your example from test_fm and include it in the help text.

Second, the help text as it stands now is wrong. The function should ask for subscripts and not for data_points. tam should be replaced by e.g. siz (see function size). The option plot is not supported in the current function. I get an error when I set three input arguments. Currently I cannot switch off the plot option and the function is extremely slow.

Third, you should run mlint since there are various warnings (e.g. memory allocation) that show that the code could be improved.

Fourth, I did not check the code properly. But there are various nested loops which may slow down calculation when the matrix domain is large. Perhaps there are ways to vectorize these loops and to improve performance of the function.

Juan Cardelino

I've corrected that. Now the expected arguments are docuemnted and with a sample. However, use only few points as input arguments. Using big random does not make any sense. At least if you want to easily understand the results.

w s

I tried following:

>> x = randn(100,1);
>> y = randn(100,1);
>> T = fast_marching([x y]);

??? Error using ==> sub2ind at 56
Out of range subscript.

Error in ==> fast_marching at 36

I guess it is the input that is wrong here, hence I tried

>> T = fast_marching(x, y);
??? Error using ==> fast_marching
Too many input arguments.

So what input required here? The help says:
punto_dato: column vector with 2-dimensional points.

Unfortunately I don't know how to create a column vector with 2-dimensional points.

Please provide a better help. I'll be happy to give a better review than.



Just added a screenshot and improved documentation.

improved documentation

improved the help and input arguments

MATLAB Release
MATLAB 7.2 (R2006a)

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

» Watch video

Win prizes and improve your MATLAB skills

Play today