File Exchange

## Toolbox Fast Marching

version 1.2.0.0 (5.8 MB) by Gabriel Peyre

### Gabriel Peyre (view profile)

A toolbox for the computation of the Fast Marching algorithm in 2D and 3D.

Updated 27 Jun 2009

The Fast Marching algorithm, introduced by Sethian (1996) is a numerical algorithm that is able to catch the viscosity solution of the Eikonal equation |grad(D)|=P. The level set {x \ F(x)=t} can be seen as a front advancing with speed P(x).

The resulting function D is a distance function, and if the speed P is constant, it can be seen as the distance function to a set of starting points.

The Fast Marching is very similar to the Dijkstra algorithm that finds shortest paths on graphs. Using a gradient descent of the distance function D, one is able to extract a good approximation of the shortest path (geodesic) in various settings (euclidean for P constant, and a weighted riemanian manifold with P varying).

The main reference about the Fast Marching algorithm is the book
Level Set Methods and Fast Marching Methods Evolving Interfaces in Computational Geometry, Fluid Mechanics, Computer Vision, and Materials Science
J.A. Sethian, Cambridge University Press, 1999
Cambridge Monograph on Applied and Computational Mathematics

A good review of the Fast Marching in 3D together with some applications can be found in
Fast extraction of minimal paths in 3D images and application to virtual endoscopy.
T.Deschamps and L.D. Cohen.
September 2000. To appear in Medical Image Analysis.

The functions 'perform_fast_marching_2d', 'perform_fast_marching_3d' and 'perform_fast_marching_mesh' compute the distance function from a set of starting points. To extract the geodesics between these starting points and an ending point, you can use 'extract_path_2d' and 'extract_path_3d'.

The main computation are done in a mex file so it is very fast (using a C++ heap structure). Precompiled version (.dll) for Windows are given.

Paul Zhang

### Paul Zhang (view profile)

had to replace some ints with mwSize in order to make mex happy.
also, missing "mex/anisotropic-fm" folder.
Otherwise works.

Dimitrie Kuhn

### Dimitrie Kuhn (view profile)

Great job! Thanks for sharing!

sagarika bora

Kerim Khemraev

Kerim Khemraev

Michael Roberts

### Michael Roberts (view profile)

I had lots of problems with the 3D code crashing the system, but managed to fix it by adding

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
perform_front_propagation_3d();
}

to the end of the perform_front_propagation_3d.cpp file. Then recompiled with

mex perform_front_propagation_3d.cpp fheap/fib.cpp

Now I can calculate the geodesic distances fine.

Please fix! There are a number of files missing including: perform_front_propagation_mesh, L2_distance

Tomasz Noga

### Tomasz Noga (view profile)

In case anyone else has similar problems, here's a potential solution - you need to add an option "-compatibleArrayDims" to the mex command, for example:

mex filename.cpp -compatibleArrayDims

Tomasz Noga

### Tomasz Noga (view profile)

Following error appears when running compile_mex (using MinGW64 Compiler):

error: cannot convert 'int*' to 'const size_t* {aka const long
long unsigned int*}' for argument '2' to 'mxArray*
mxCreateNumericArray_730(size_t, const size_t*, mxClassID,
mxComplexity)'
plhs[2] = mxCreateNumericArray(3, dims, mxDOUBLE_CLASS,
mxREAL );

perform_front_propagation_2d.cpp and perform_circular_front_propagation_2d.cpp work fine, only perform_front_propagation_3d.cpp causes trouble

Can anyone help?

The

harnoorsaini

### harnoorsaini (view profile)

dosnt compile, some files missing

Damian Kaniewski

Kevin Gobron

ran fang

### ran fang (view profile)

Thank you for sharing . I find the "perform_front_propagation_mesh.mexw64" MEX function from the "Segmentation" program appears to be the one that caused MATLAB to crash. Help!

hsdg vfra

### hsdg vfra (view profile)

Thank you for sharing a seemingly great toolbox. Although I don't intend to use " perform_fast_marching_mesh", it calls an error: Undefined function 'perform_front_propagation_mesh' for input arguments of type 'double'.
Error in compile_mex (line 63).
However, that I have downloaded all the full toolbox Toolbox (Fast Marching) from this site.

-S. E.

sagarika bora

### sagarika bora (view profile)

Alexander Naitzat

### Alexander Naitzat (view profile)

Is there support for tetrahedral meshes ? I need to perform fast marching algorithm on tetrahedral meshes. I'll be grateful if somebody can help me find a relevant matlab code.

tao jiang

### tao jiang (view profile)

thanks for sharing!

Sarun

### Sarun (view profile)

I normally set options.method = 'discrete' for 'compute_geodesic' function and never have a problem. If not, sometimes the path doesn't reach all the way to start_points. And 'perform_fast_marching' seems to stop as soon as it reaches one of end_points.

Jay Guo

### Jay Guo (view profile)

Thank you for share this great job for us!I am doing research on Seismic ray tracing, so I am very interested in 'perform_fast_marching.m' and 'compute_geodesic'.It has been confusing me that not every end_point can be reached from start_point. In many times, I cannot get a full path. Could you give me some advices or help,plz.

Jay Guo

Javier V Gomez

### Javier V Gomez (view profile)

I am the author of the website of the previous comment. Here is an updated version: http://javiervgomez.com/pages/fast-marching-toolbox-installation-tutorial.html

robinvista

### robinvista (view profile)

This webpage gives some help of the configuration of the package:
http://sgpsproject.sourceforge.net/JavierVGomez/index.php/FM_Toolbox

robinvista

dhara

### dhara (view profile)

great toolbox... but i am facing problem with compile mex file.plz anyone help me out...

Error: Error using mex
unable to complete successfully.
i dont have much ide about compile c file in matlab also..may be it is my error but plz help me.

Seung-Goo

### Seung-Goo (view profile)

Thank you for sharing a seemingly great toolbox. But like some users, I also failed to compile mex files. Although I don't intend to use "perform_front_propagation_anisotropic", it calls an error:
Unable to complete successfully.

Error in compile_mex (line 7)
mex mex/anisotropic-fm//perform_front_propagation_anisotropic.cpp

leaving perform_front_propagation_mesh, which I wish to use, not compiled.

So I just commented the line 7 in "compile_mex.m", which reads "% mex mex/anisotropic-fm//perform_front_propagation_anisotropic.cpp".

Then compile_mex.m returns a bunch of warnings but it ends without errors. and the functions seem to work, I guess. I wish the author update/modify the compile_mex.m to bypass such errors, and hope this helps others having this error, although I'm not sure if this introduces some insane behaviors or not.

-SG

Ozan Oktay

### Ozan Oktay (view profile)

You can find the missing files using the following link:

("AnisotropicTensorDistance.h")
("AnisotropicTensorDistanceConfidence.h")

Denny Milakara

### Denny Milakara (view profile)

Any chance soon to see debugged version?

John

### John (view profile)

It appears that the author has done no regression testing. I can't get any non-trivial test script to work out of the box. Every 5 star rating is by someone who took the time to debug the author's submission. Sadly, the author does not appear to have updated his submission to reflect all these bug fixes.

asthana

### asthana (view profile)

hello sir i want to make a weighted function for gray image using distance,direction, and level. weighted funtion = distance*level*direction. is there any file in his toolbox which is helpfull for me? if is there any then please inform me. i want this urgent please please suggest me how to do so..

Sarun

### Sarun (view profile)

Works great for fast marching. Some files cannot be compiled so just comment them out. compute_geodesic is a bit buggy but code is easy to understand and fix it.

Dami

### Dami (view profile)

Hi Gabe, Thanks for the upload! perform_front_propagation_2d.m seems to be empty (contains only comments), and there's no perform_front_propagation_3d.m file. I try to run perform_fast_marching and I get this error message:

Undefined function or method 'perform_front_propagation_3d' for input arguments of
type 'double'.

Error in ==> perform_fast_marching_old at 114
[D,S,Q] = perform_front_propagation_3d(W,start_points-1,end_points-1,nb_iter_max,
H, L, values);

Would appreciate help with this. Thanks.

Ben

### Ben (view profile)

Someone have used the skeleton on 3D data?

Wok

Zohar

### Zohar (view profile)

The mesh propagation works well, thanks.
The 3D propagation is slow (compared to the Accurate Fast Marching) and returns wrong results: Add the line

W = ones(size(W));

to

test_fast_marching_3d.m

and check the distance matrix result.

Christopher Hyatt

### Christopher Hyatt (view profile)

It appears that the two M-files 'extract_path_2/3d.m' have been replaced by 'compute_geodesic.m'.

The functions extract_path_2d() and extract_path_3d() are actually inside the 'compute_geodesic.m' file.

Anton Semechko

### Anton Semechko (view profile)

Anyone get an error:

"??? Undefined function or method 'perform_front_propagation_mesh' for input arguments of type 'double'."

when trying to perform fast marching on a surface mesh? The contents of the entire toolbox have been added to the path, so it appears that perform_front_propagation_mesh.m was not provided by author.

Xuemei

### Xuemei (view profile)

I just download and use test_fast_marching_2d.m, it goes well although a bit error should be debugged. Thats easy to correct. So, well done. A good work on fast marching methods. I will further use this toobox on my project.

Eitan

### Eitan (view profile)

Hi,

I am trying to use this toolbox for segmenting a 3D mesh. The mesh contains several unconnected surfaces.It seems that the fast marching algorithm "jumps" over the gap between the surfaces. Is it possible? I would expect the geodesic distance between unconnected nodes to be Inf.

Thanks,
Eitan

D L

### D L (view profile)

I encountered this error while trying to run compile_mex

mex: mex/anisotropic-fm//perform_front_propagation_anisotropic.cpp not a normal file or does not exist.

??? Error using ==> mex at 222
Unable to complete successfully.

Error in ==> compile_mex at 7
mex mex/anisotropic-fm//perform_front_propagation_anisotropic.cpp

Any help is appreciated. Thank you in advance.

Thank you for sharing this program,
I have a question regarding it:

You mentioned it above extract_path_2d.m (and the 3d also) but I cannot find it, even in the files list. For more when runing test_fast_marching_2d.m this error occurs

??? Index exceeds matrix dimensions.

Error in ==> perform_front_propagation_2d_slow>perform_fast_marching_step at 110
h0=H(ind_O);

Error in ==> perform_front_propagation_2d_slow at 56
data = perform_fast_marching_step(data);

Error in ==> perform_fast_marching at 117
[D,S] =
perform_front_propagation_2d_slow(W,start_points,end_points,nb_iter_max, H);

Error in ==> test_fast_marching_2d at 27
[D,S] = perform_fast_marching(W, start_points, options);

I would appreciate if you could help

LAZRAG Hassen

### LAZRAG Hassen (view profile)

thank you a lot for this method. But can you give me an idea about how to use it for medical image segmentation ( tumor extraction)

JotauVe

JotauVe

### JotauVe (view profile)

Hi,

I want to know if the extract_path_2d.m (and the 3d also) is included in this toolbox.

You mentioned it above but I cannot find it, even in the files list.

Thank you very much.

Dim

### Dim (view profile)

Hello,

first of all i would like to congratulate you for this excelent work.
It seems i have a problem with the precompiled dll of 'perform_fast_marching_2d'.

More specifically (while i was trying to perform teh example posted at http://www.ceremade.dauphine.fr/~peyre/numerical-tour/tours/shapes_5_geodesic_descriptors/#10, i received the above error message:
??? Attempt to execute SCRIPT perform_front_propagation_2d as a function:

Error in ==> perform_fast_marching at 115
[D,S,Q] = perform_front_propagation_2d(W,start_points-1,end_points-1,nb_iter_max, H,
L, values);

What i understood is that it cant see the dll function.

Any suggestion is welcome.

Gabriel Peyre

### Gabriel Peyre (view profile)

IMPORTANT:

1) The code for the anisotropic propagation is not included anymore in the toolbox, so do not try to compile it. Contact me if you *really* need anisotropic propagation.

2) Although this toolbox works fine, it is not "plug and play". If you want an introduction to Fast Marching method, you should try my Numerical Tours
www.numerical-tours.com

Jerry

### Jerry (view profile)

lack of many files. such as perform_front_propagation_anisotropic.h
AnisotropicTensorDistanceConfidence.h

lack of the file you mentioned in the compile_mex anisotropic-fm
you have provided the mac os head

ma qingfeng

### ma qingfeng (view profile)

Error in ==> perform_fast_marching at 117
[D,S] = perform_front_propagation_2d(W,start_points,end_points,nb_iter_max,
H);

Error in ==> test_fast_marching_2d at 25
[D,S] = perform_fast_marching(W, start_points, options);

wang jinguo

### wang jinguo (view profile)

Thank you for your share!But there is a error that mex/perform_front_propagation_2d.cpp' not found,when i run compile_mex file.So i wanna get your help! Thanks!

wang jinguo

Percy Deng

### Percy Deng (view profile)

Yes, a bunch of errors, and a great many files missed, how could anybody successfully compile it?

Kevin

### Kevin (view profile)

First I had troubles with compile_mex. Some paths were wrong and files were missing (the whole anisotropic-fm folder), and I had to download them manually on INRIA's. Even then, the file wouldn't compile.

A bit of a disappointment given the obvious effort that was put into the project.

John Sarkar

### John Sarkar (view profile)

It seems good code bur very bad organized! Lots of bugs...too many subfolders...Non of tests did not work for me!

Pascal

### Pascal (view profile)

The author did a terrific job with the toolbox and demos!

However, too many bugs and compilation errors occur (i.e. similar to those expressed by prior user comments, as well as, the function: fm2dAniso)

Raymond Cheng

### Raymond Cheng (view profile)

Thanks for sharing.

Merci beaucoup Peyre for sharing et aussi pour superbe site avec many explanations.

Nora

### Nora (view profile)

The idea is great, keep on going! The code still needs some improvement though (bug fixing).
I used it for 2D fast marching, but found that matlab bwdist performs way faster, even if I truncate the region to calculate.

Martin

### Martin (view profile)

Works fine for me. Thank you very much.

vincent w

too many bugs... please fix them before sharing. othewise what you r doing is just wasting the time of other people.

Thao Tran

Thank you very much for your sharing.
But when I test in 3D,it warns errors:
:
--> Perform Fast Marching ... ??? Error using ==> perform_front_propagation_3d
end_points must be of size 3 x nb_end_poins.

Error in ==> perform_fast_marching at 121
[D,S,Q] = perform_front_propagation_3d(W,start_points-1,end_points-1,nb_iter_max, H, L,
values);

Error in ==> test_vol3d at 61
[D,S] = perform_fast_marching(W, start_point, options);

??? Error using ==> perform_front_propagation_3d
end_points must be of size 3 x nb_end_poins.

Error in ==> perform_fast_marching at 121
[D,S,Q] = perform_front_propagation_3d(W,start_points-1,end_points-1,nb_iter_max, H, L,
values);

Error in ==> test_fast_marching_3d at 19
[D,S] = perform_fast_marching(W, start_points, options);

Who can tell me how to solve the problems?

Mehul Sampat

I was trying to run the test_active_contour.m file. I get the following error message: "Undefined function or method 'perform_conjugate_gradient' for input arguments of type 'function_handle'."

I tried to find the perform_conjugate_gradient fn but could not locate it in the toolbox. Could you please provide the source for this function ?
Thanks

LI BO

Thanks for sharing

ran hongge

while i am debugging,test_fmstar_2d.m can not get a result.There are always an error:-----------------------------------------------------------------------
Segmentation violation detected at Thu Sep 06 10:15:31 2007
------------------------------------------------------------------------

Configuration:
MATLAB Version: 7.0.0.19920 (R14)
Operating System: Microsoft Windows XP
Window System: Version 5.1 (Build 2600: Service Pack 2)
Processor ID: x86 Family 15 Model 2 Stepping 9, GenuineIntel
Virtual Machine: Java 1.4.2 with Sun Microsystems Inc. Java HotSpot(TM) Client VM
(mixed mode)
Default Charset: ibm-1386_P100-2002

Register State:
EAX = 00000000 EBX = 00000000
ECX = 00000000 EDX = 00000000
ESI = 00000000 EDI = 0acbeb84
EBP = 00cdb88c ESP = 00cdb760
EIP = 0acb153a FLG = 00010246

Stack Trace:
[0] perform_circular_front_propagation_2d.dll:0x0acb153a(0x0acb1238, 0x00cdc4c0, 0, 0)
[1] perform_circular_front_propagation_2d.dll:0x0acb148c(2, 0x00cdc4c0, 5, 0x00cdc550)
[2] libmex.dll:_mexRunMexFile(2, 0x00cdc4c0, 5, 0x00cdc550) + 71 bytes
[3] libmex.dll:public: virtual void __thiscall Mfh_mex::dispatch_file(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(2, 0x00cdc4c0, 5, 0x00cdc550) + 157 bytes
[4] m_dispatcher.dll:public: virtual void __thiscall Mfh_file::dispatch_fh(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(2, 0x00cdc4c0, 5, 0x00cdc550) + 273 bytes
[5] m_interpreter.dll:public: void __thiscall ResolverFunctionDesc::CallFunction(int,struct mxArray_tag * * const,int,struct mxArray_tag * * const)(2, 0x00cdc4c0, 5, 0x00cdc550) + 246 bytes
[6] m_interpreter.dll:public: bool __thiscall Resolver::CallMFunction(int,int,class _m_operand * const,union m_operand_storage *,int,class _m_operand * const,union m_operand_storage *,int *)(2, 2, 0x01527b90, 0) + 840 bytes
[7] m_interpreter.dll:bool __cdecl inResolveMFunctionCall(struct _m_function_desc *,int,int,class _m_operand * const,union m_operand_storage *,int,class _m_operand * const,union m_operand_storage *,int *,enum inMarshalType *,unsigned int,int,unsigned int *,int)(0x22b05a50, 2, 2, 0x01527b90) + 148 bytes
[8] m_interpreter.dll:bool __cdecl accelMFunctionCall(struct _accelOp *,struct _accelOp * *,struct _accelBytecode *,int *,enum inMarshalType *)(0x22b9f860, 0x00cdcb64 "????, 0x013257b0, 0x00cdcb5c) + 108 bytes
[9] m_interpreter.dll:int __cdecl accelExec(struct _accelBytecode *,enum inMarshalType *)(0x013257b0, 0x00cdcbdc, 0, 0) + 18462 bytes
[10] m_interpreter.dll:_inExecuteHotSegment(0x00cdcc10, 0x00cdcce0, 0x00cdcc90, 0) + 1542 bytes
[11] m_interpreter.dll:int __cdecl inInterp(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest_tag volatile *)(1, 541, 56, 0) + 365 bytes
[12] m_interpreter.dll:int __cdecl inInterPcodeSJ(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest_tag *)(1, 541, 23, 0) + 272 bytes
[13] m_interpreter.dll:int __cdecl inExecuteMFunctionOrScript(class Mfh_mp *,bool)(0x22b86760, 0, 4, 5) + 773 bytes
[14] m_interpreter.dll:_inWordsj(2, 0x00cdd1fc, 4, 0x00cdd25c) + 441 bytes
[15] m_interpreter.dll:public: void __thiscall Mfh_mp::inRunMP(int,struct mxArray_tag * *,int,struct mxArray_tag * *,struct inWorkSpace_tag *)(2, 0x00cdd1fc, 4, 0x00cdd25c) + 158 bytes
[16] m_interpreter.dll:public: virtual void __thiscall Mfh_mp::dispatch_file(struct _mdUnknown_workspace *,int,struct mxArray_tag * *,int,struct mxArray_tag * *)(0, 2, 0x00cdd1fc, 4) + 28 bytes
[17] m_interpreter.dll:public: virtual void __thiscall Mfh_mp::dispatch_file(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(2, 0x00cdd1fc, 4, 0x00cdd25c) + 26 bytes
[18] m_dispatcher.dll:public: virtual void __thiscall Mfh_file::dispatch_fh(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(2, 0x00cdd1fc, 4, 0x00cdd25c) + 273 bytes
[19] m_interpreter.dll:_inDispatchFromStack(670, 0x22bad12c "perform_circular_fast_marching_2..", 2, 4) + 891 bytes
[20] m_interpreter.dll:enum opcodes __cdecl inDispatchCall(char const *,int,int,int,int *,int *)(0x22bad12c "perform_circular_fast_marching_2..", 670, 2, 4) + 111 bytes
[21] m_interpreter.dll:int __cdecl inInterp(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest_tag volatile *)(1, 604, 42, 0) + 2282 bytes
[22] m_interpreter.dll:int __cdecl inInterPcodeSJ(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest_tag *)(1, 604, 4, 0) + 272 bytes
[23] m_interpreter.dll:int __cdecl inExecuteMFunctionOrScript(class Mfh_mp *,bool)(0x22b84230, 0, 3, 3) + 773 bytes
[24] m_interpreter.dll:_inWordsj(1, 0x00cdd91c, 3, 0x00cdd97c) + 441 bytes
[25] m_interpreter.dll:public: void __thiscall Mfh_mp::inRunMP(int,struct mxArray_tag * *,int,struct mxArray_tag * *,struct inWorkSpace_tag *)(1, 0x00cdd91c, 3, 0x00cdd97c) + 158 bytes
[26] m_interpreter.dll:public: virtual void __thiscall Mfh_mp::dispatch_file(struct _mdUnknown_workspace *,int,struct mxArray_tag * *,int,struct mxArray_tag * *)(0, 1, 0x00cdd91c, 3) + 28 bytes
[27] m_interpreter.dll:public: virtual void __thiscall Mfh_mp::dispatch_file(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(1, 0x00cdd91c, 3, 0x00cdd97c) + 26 bytes
[28] m_dispatcher.dll:public: virtual void __thiscall Mfh_file::dispatch_fh(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(1, 0x00cdd91c, 3, 0x00cdd97c) + 273 bytes
[29] m_interpreter.dll:_inDispatchFromStack(665, 0x22abdafc "compute_heuristic_multiresolutio..", 1, 3) + 891 bytes
[30] m_interpreter.dll:enum opcodes __cdecl inDispatchCall(char const *,int,int,int,int *,int *)(0x22abdafc "compute_heuristic_multiresolutio..", 665, 1, 3) + 111 bytes
[31] m_interpreter.dll:int __cdecl inInterp(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest_tag volatile *)(1, 874, 55, 0) + 2282 bytes
[32] m_interpreter.dll:int __cdecl inInterPcodeSJ(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest_tag *)(1, 874, 24, 0) + 272 bytes
[33] m_interpreter.dll:int __cdecl inExecuteMFunctionOrScript(class Mfh_mp *,bool)(0x22a47af0, 0, 4, 4) + 773 bytes
[34] m_interpreter.dll:_inWordsj(2, 0x00cde03c, 4, 0x00cde09c) + 441 bytes
[35] m_interpreter.dll:public: void __thiscall Mfh_mp::inRunMP(int,struct mxArray_tag * *,int,struct mxArray_tag * *,struct inWorkSpace_tag *)(2, 0x00cde03c, 4, 0x00cde09c) + 158 bytes
[36] m_interpreter.dll:public: virtual void __thiscall Mfh_mp::dispatch_file(struct _mdUnknown_workspace *,int,struct mxArray_tag * *,int,struct mxArray_tag * *)(0, 2, 0x00cde03c, 4) + 28 bytes
[37] m_interpreter.dll:public: virtual void __thiscall Mfh_mp::dispatch_file(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(2, 0x00cde03c, 4, 0x00cde09c) + 26 bytes
[38] m_dispatcher.dll:public: virtual void __thiscall Mfh_file::dispatch_fh(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(2, 0x00cde03c, 4, 0x00cde09c) + 273 bytes
[39] m_interpreter.dll:_inDispatchFromStack(664, 0x0f7ca247 "perform_fmstar_2d", 2, 4) + 891 bytes
[40] m_interpreter.dll:_inCallFcnFromReference(0, 0x0f872730, 0x789b59c0, 0xcccccccd) + 176 bytes
[41] m_interpreter.dll:int __cdecl inInterp(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest_tag volatile *)(1, 0, 93, 0) + 4115 bytes
[42] m_interpreter.dll:int __cdecl inInterPcodeSJ(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest_tag *)(1, 0, 14, 0) + 272 bytes
[43] m_interpreter.dll:int __cdecl inExecuteMFunctionOrScript(class Mfh_mp *,bool)(0x015e6f30, 1, 0, 0x015e6f30) + 773 bytes
[44] m_interpreter.dll:_inExecCompScript(0, 0x00cde71c, 0x015e6f30, 0xffffffff) + 321 bytes
[45] m_interpreter.dll:public: void __thiscall Mfh_mp::inRunMP(int,struct mxArray_tag * *,int,struct mxArray_tag * *,struct inWorkSpace_tag *)(0, 0x00cde71c, 0, 0x00cde77c) + 122 bytes
[46] m_interpreter.dll:public: virtual void __thiscall Mfh_mp::dispatch_file(struct _mdUnknown_workspace *,int,struct mxArray_tag * *,int,struct mxArray_tag * *)(0, 0, 0x00cde71c, 0) + 28 bytes
[47] m_interpreter.dll:public: virtual void __thiscall Mfh_mp::dispatch_file(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(0, 0x00cde71c, 0, 0x00cde77c) + 26 bytes
[48] m_dispatcher.dll:public: virtual void __thiscall Mfh_file::dispatch_fh(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(0, 0x00cde71c, 0, 0x00cde77c) + 273 bytes
[49] m_interpreter.dll:_inDispatchFromStack(488, 0x013f6d84 "test_fmstar_2d", 0, 0) + 891 bytes
[50] m_interpreter.dll:enum opcodes __cdecl inDispatchCall(char const *,int,int,int,int *,int *)(0x013f6d84 "test_fmstar_2d", 488, 0, 0) + 111 bytes
[51] m_interpreter.dll:int __cdecl inInterp(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest_tag volatile *)(2, 0, 0, 0) + 2411 bytes
[52] m_interpreter.dll:int __cdecl inInterPcodeSJ(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest_tag *)(2, 0, 0, 0) + 272 bytes
[53] m_interpreter.dll:_inInterPcode(2, 0x7876f2d8, 0, 0) + 69 bytes
[54] m_interpreter.dll:enum inExecutionStatus __cdecl in_local_call_eval_function(int *,struct _pcodeheader *,int *,struct mxArray_tag * * const,enum inDebugCheck)(0x00cdf2c8, 0x00cdf3bc, 2, 0x0f525010 "test_fmstar_2d\n") + 162 bytes
[55] m_interpreter.dll:\$L72592(0x7876f2d8, 0x0f525010 "test_fmstar_2d\n", 15, 0) + 196 bytes
[56] m_interpreter.dll:enum inExecutionStatus __cdecl inEvalCmdWithLocalReturnandtype(char const *,int *,enum inDebugCheck)(0, 2, 1, 0x00cdf44c "??) + 86 bytes
[57] m_interpreter.dll:_inEvalCmdNoEnd(0x0f525010 "test_fmstar_2d\n", 0x00cdf4e4, 0x00cdf4a0, 0x015c2180) + 16 bytes
[58] bridge.dll:_mnParser(0x7c80b6a1, 0x015c2180, 0, 0) + 431 bytes
[59] mcr.dll:public: void __thiscall mcrInstance::mnParser(void)(271242, 0x4d5c3a44, 0x414c5441, 0x625c3742) + 87 bytes
[60] MATLAB.exe:0x00401d2f(4194304, 0, 271242, 0x015c2180)
[61] MATLAB.exe:0x00403e45(3276856, 2949175, 0x7ffde000, 0x8054b938)
[62] kernel32.dll:0x7c816fd7(0x00403cc0 "jth(U@", 0, 0, 0)

This error was detected while a MEX-file was running. If the MEX-file
is not an official MathWorks function, please examine its source code
for errors. Please consult the External Interfaces Guide for information
on debugging MEX-files.

philipe gabriel

Very good job, it work 5/5 but i need this program in C++ compilator if you can give it to me

thanks

Sina Jahanbin

Excellent toolbox!!! I have tested the fast marching algorithm on 3D meshes and it works perfect! Thanks Gabriel for sharing it!

Oliver W

Excellent and very useful, but there is a small bug in perform_front_propagation_3d.cpp. In the function check_heap the condition on the third 'for loop' should be z<q rather than z<p.
Thanks

Jesus Diaz Carazo

Very good job. You will be in the acknowledgment part of my project report. Mes felicitations!

Peng mingzi

It is a nice tool for us,thanks for your help.but when I do the mex file I have met the follow question ,could everyone can help me,thanks .
The proplem is:
perform_front_propagation_2d.obj : error LNK2001: unresolved external symbol _mexErrMsgTxt
perform_front_propagation_2d.obj : error LNK2001: unresolved external symbol "void __cdecl fh_deleteheap(struct fibheap *)" (?fh_deleteheap@@YAXPAUfibheap@@@Z)
perform_front_propagation_2d.obj : error LNK2001: unresolved external symbol "void * __cdecl fh_replacedata(struct fibheap *,struct fibheap_el *,void *)" (?fh_replacedata@@YAPAXPAUfibheap@@PAUfibheap_el@@PAX@Z)
perform_front_propagation_2d.obj : error LNK2001: unresolved external symbol "void * __cdecl fh_extractmin(struct fibheap *)" (?fh_extractmin@@YAPAXPAUfibheap@@@Z)
perform_front_propagation_2d.obj : error LNK2001: unresolved external symbol "bool __cdecl fh_isempty(struct fibheap const *)" (?fh_isempty@@YA_NPBUfibheap@@@Z)
perform_front_propagation_2d.obj : error LNK2001: unresolved external symbol "struct fibheap_el * __cdecl fh_insert(struct fibheap *,void *)" (?fh_insert@@YAPAUfibheap_el@@PAUfibheap@@PAX@Z)
perform_front_propagation_2d.obj : error LNK2001: unresolved external symbol "int (__cdecl*__cdecl fh_setcmp(struct fibheap *,int (__cdecl*)(void *,void *)))(void *,void *)" (?fh_setcmp@@YAP6AHPAX0@ZPAUfibheap@@P6AH00@Z@Z)
perform_front_propagation_2d.obj : error LNK2001: unresolved external symbol "struct fibheap * __cdecl fh_makeheap(void)" (?fh_makeheap@@YAPAUfibheap@@XZ)
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/perform_front_propagation_2d.exe : fatal error LNK1120: 9 unresolved externals

Santiago Garrido

When I have run the function "test_multiple_paths_2d", I've got the below error:
Performing front propagation.
Extracting path.
??? Function 'minus' is not defined for values of class 'cell'.

Error in ==> compute_distance_to_points at 20
D(k,:) = sum( (X - repmat(seeds(:,k),1,n)).^2 );

Error in ==> extract_path_2d at 66
d = compute_distance_to_points(path', start_points);

Error in ==> test_multiple_paths_2d at 33
paths1 = extract_path_2d(D,end_points, options);

Liran Liran

Hi,

I have tried to use this toolbox on
Matlab R2006a
and I got the below error.

Thanks,

Liran

??? Invalid MEX-file 'C:\liran\matlab\fastMarching\toolbox_fast_marching\perform_front_propagation_2d.dll': The specified module could not be found.

.

Error in ==> perform_fast_marching_2d at 50
[D,S] = perform_front_propagation_2d(W,start_points-1,end_points-1,nb_iter_max);

Error in ==> test_fast_marching_2d at 21
[D,S] = perform_fast_marching_2d(W, start_points, options);

>> dir perform_front_propagation_2d.dll

perform_front_propagation_2d.dll

Dan Dan

This is the best level set implementation tutorial I ever found.

thank you:)
-Dan

gianni schena

TO : Beth Massey(emassey@fit.edu)
sorry but perform_ circular_front_propagation WORKS fine on my PC; check twice your installation !

Beth Massey

I couldn't get any of the test files to work in the toolbox_fast_marching folder. The errors I get are:
??? Invalid MEX-file 'C:\Documents and Settings\Beth\Desktop\LevelSetMethods\peyrefmm\toolbox_fast_marching\perform_circular_front_propagation_2d.dll': The specified module could not be found.

Error in ==> perform_circular_fast_marching_2d at 57
[D,S] = perform_circular_front_propagation_2d(W,start_points-1,end_points-1,center_point-1,nb_iter_max);

Error in ==> test_circular at 60
[D,S] = perform_circular_fast_marching_2d(W, start_points, center_point, options);

Any help would be appreciated

lucia Come

It works perfectly in 2d & 3D !
Since multiple paths may overlap (...to say the 3rd decimal point precision) it would be nice (and save memory) to have the possibility to trim away path sections in common ; we will have more paths and shorter but no duplication of paths

Pierre Scardanzan

great tool for endoscopy !
one question: how can I relate path (x,y,z) to W(i,j,k) ? i.e. how to get the value of the speed function that is given at voxel location to the path coordinates given as real values ? is there a trick to go from x,y,z to i,j,k quickly ?

Gang Li

Does anybody know how to complie the *.cpp file in the toolbox to *.dll,as I want do some modification on the cpp code? Thanks very much!

S E

This would be awfully useful if I could make it work! The mex-file fails as below; the slow .m version fails for other reasons.

test_fast_marching_2d
Pick starting point.
Pick end point.
Performing front propagation.
DLL load failed for mex file C:\_Lens\Tools\Matlab\Fast Marching\perform_front_propagation_2d.dll
The specified module could not be found.
??? Invalid MEX-file

Error in ==> C:\_Lens\Tools\Matlab\Fast Marching\perform_fast_marching_2d.m
On line 50 ==> [D,S] = perform_front_propagation_2d(W,start_points-1,end_points-1,nb_iter_max);

Error in ==> C:\_Lens\Tools\Matlab\Fast Marching\test_fast_marching_2d.m
On line 21 ==> [D,S] = perform_fast_marching_2d(W, start_points, options);

eehui lim

i can run test_circular_fast_marching_2d but get errors when running this:
>> test_fast_marching_2d
Pick starting point.
Pick end point.
Performing front propagation.
Extracting path.
Elapsed time is 0.051000 seconds.
??? Undefined command/function 'extract_curves'.

Error in ==> plot_fast_marching_2d at 51
c_list = extract_curves(S,0);

Error in ==> test_fast_marching_2d at 27
plot_fast_marching_2d(W,S,path,start_points,end_points);

>>

and this:
>> test_fast_marching_3d
??? end_points must be of size 3 x nb_end_poins.

Error in ==> perform_fast_marching_3d at 56
[D,S] = perform_front_propagation_3d(W,start_points-1,end_points-1,nb_iter_max);

Error in ==> test_fast_marching_3d at 19
[D,S] = perform_fast_marching_3d(W, start_points, options);

also can i know is there any examples in 3D range data segmentation or 2d image segmentation with fast marching? Thanks very much for your efforts.

Santiago Garrido

When I run 'test_circular' I was told:
??? Undefined command/function 'image_resize'.

Markus Weigert

Great Stuff,
I used a modification of an older version in my diploma thesis for 3D - Image segmentation.

Thank you very much for your efforts.

Gabriel Peyré

Sorry, you should change the compile_mex function so that it includes the heap files:

mex mex/perform_front_propagation_2d.cpp mex/perform_front_propagation_2d_mex.cpp mex/fheap/fib.cpp
mex mex/perform_front_propagation_3d.cpp mex/fheap/fib.cpp
mex mex/perform_circular_front_propagation_2d.cpp mex/perform_front_propagation_2d.cpp mex/fheap/fib.cpp

canfei li

when I compiling the mex files I was told that
perform_front_propagation_3d.obj
Creating library _lib6913.x and object _lib6913.exp
perform_front_propagation_3d.obj : error LNK2001: unresolved external symbol "void __cdecl fh_deleteheap(struct fibheap *)" (?fh_deleteheap@@YAXPAUfibheap@@@Z)
perform_front_propagation_3d.obj : error LNK2001: unresolved external symbol "void * __cdecl fh_replacedata(struct fibheap *,struct fibheap_el *,void *)" (?fh_replacedata@@YAPAXPAUfibheap@@PAUfibheap_el@@PAX@Z)
perform_front_propagation_3d.obj : error LNK2001: unresolved external symbol "void * __cdecl fh_extractmin(struct fibheap *)" (?fh_extractmin@@YAPAXPAUfibheap@@@Z)
perform_front_propagation_3d.obj : error LNK2001: unresolved external symbol "bool __cdecl fh_isempty(struct fibheap const *)" (?fh_isempty@@YA_NPBUfibheap@@@Z)
perform_front_propagation_3d.obj : error LNK2001: unresolved external symbol "struct fibheap_el * __cdecl fh_insert(struct fibheap *,void *)" (?fh_insert@@YAPAUfibheap_el@@PAUfibheap@@PAX@Z)
perform_front_propagation_3d.obj : error LNK2001: unresolved external symbol "int (__cdecl*__cdecl fh_setcmp(struct fibheap *,int (__cdecl*)(void *,void *)))(void *,void *)" (?fh_setcmp@@YAP6AHPAX0@ZPAUfibheap@@P6AH00@Z@Z)
perform_front_propagation_3d.obj : error LNK2001: unresolved external symbol "struct fibheap * __cdecl fh_makeheap(void)" (?fh_makeheap@@YAPAUfibheap@@XZ)
perform_front_propagation_3d.dll : fatal error LNK1120: 7 unresolved externals

C:\MATLAB6P5P1\BIN\WIN32\MEX.PL: Error: Link of 'perform_front_propagation_3d.dll' failed.

Thomas Deschamps

Merci pour la reference au passage!

canfei li

1. During the decompressing file ,It told me that it couldn't open the file 'perform_front_propagation.suo '. so after I decompressed the files ,I couldn't find the file .
2.when I run compile mex file,I was told that
Error in ==> C:\MATLAB6p5p1\toolbox\toolbox_fast_marching\compile_mex.m
On line 3 ==> mex mex/perform_front_propagation_3d.cpp

Gabriel Peyré

The path extraction is slow because it uses Matlab EDO features. The front propagation is as fast as it can be (just C code ...). I'll try to post a simpler path extraction code that runs faster.

BTW, just giving a bad rating is useless. Coding a complete library is a complex task, and just posting anonymous ratings is so easy ...
Try instead to send me a personnal email, I'll try to correct the bugs.

BTW2: the code runs perfectly under matlab 7. You need a C++ compiler to compile the mex files.

BTW3: what's the hell does "not self contained" means? Not enough documentation? Some files are missing (remember you have to add the directory toolbox/ to your path)? The new version contains a readme file, try to check if it does not answer to some of your questions.

A B

runs too slow! Not self contained

Yuriy Mishchenko

Tried to run but crashed on matlab 7. Very insufficiently documented. Good idea but poor implementation. In the end of the day will have to code it myself.

Raoul-Roman Kühn

3D Problem is working fine. Problems with rescale function in test_fast_marching_2d.
Error in ==> test_fast_marching_2d at 10
W = rescale( double(W) ); Using 7.0.0.19920 (R14)

Ingrid Yingge

While I can not compile it, also because the mex.h header file is missing.

Could you pls. send it to me too?

Zack Thunemann

I would like to try out this algorithm, but I'm running Matlab from a Unix machine. Is there a way to get the source code? I see that some of it is available in the download, but the mex.h header file is missing. Could you send it to me?

Thanks!

-Zack

Clement Petres

very useful but problems with multiple start points : segmentation violation !

che chou

good good good

gianni schena

working fine with the 2 functions obtained by the author.

Gabriel Peyré

Sorry, I'll try to update the toolbox in the next days. Here are the functions :

function m = mmax(A)
m = max(A(:));

function y = rescale(x,a,b)
if nargin<3
a = 0; b = 1;
end
m = min(x(:));M = max(x(:));
y = (b-a) * (x-m)/(M-m) + a;

Pierre Scardanzan

>> test_fast_marching_3d
??? Undefined function or variable 'mmax'.

Error in ==> C:\toolbox_fast_marching\extract_path_3d.m
On line 24 ==> A1 = A; A1(I) = mmax(A(J));

Error in ==> C:\toolbox_fast_marching\test_fast_marching_3d.m
On line 20 ==> path = extract_path_3d(D,end_points);

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

### Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.