[Insight-users] FastMarchingImageFilter seg fault = Negative Spacing

Mathieu Malaterre malat@free.fr
Tue, 28 Jan 2003 15:52:30 +0100


Luis,
    I am still amazed that you can find time to answer emails and 
continue developping ITK. Give your trick !
    Anyway I still have some questions about my preceeding email.

- What if I add (in itkRecursiveGaussianImageFilter.txx  ):
m_Spacing = fabs(m_Spacing);    //line 52 before  if( m_Spacing < 
spacingTolerance)

this shouldn't make any difference as finite difference are magnitude 
based.
What I don't know is if other filters might complain about that. What do 
you think ?

- I am using CT image with a scalar range of :(0.0, 870.0). If I read my 
image in binary or ascii through a python+vtk script this is ok. But 
when I use RegionGrowingSegmentation there is a difference. 
RegionGrowingSegmentation can only read properly ascii data file. Is ITK 
although assuming a range of (0, 255) all over the place ?

thanks
mathieu



Luis Ibanez wrote:

>
> Hi Mathieu,
>
> The short answer is that ITK is quite unhappy
> with the negative spacing in your image.
>
>
> The long answer is that the RecursiveGaussianImageFilter
> used to compute the Gradient Magnitude, takes the spacing
> into consideration for the computation. ITK is assuming
> positive spacings all over the place.
>
>
>
> Now, just to recover your faith on the beauty of the
> FastMarchingImageFilter, please do the following
> exercise:
>
>
> 1) Take the simple program ImageReadWrite.cxx
>
>    In the directory
>
>        Insight/Examples/IO
>
>    Modify the code to make Dimension = 3
>    instead of Dimension = 2.
>
>    Recompile it.
>
>    Then, you get for free a file format converter
>    from MetaImage to VTK and back.
>
>    Not bad for 5 minutes of work     :-)
>
>
> 2) Take any of the BrainWeb volumes in the ftp site
>
>     ftp://public.kitware.com/pub/itk/Data/
>
>     download it, expand the tgz.
>
>     and execute (for example):
>
>     ImageReadWrite  brainweb010102.mha  brainweb010102.vtk
>
>     This command line will read the BrainWeb
>     volume from the MetaImage format and save it
>     in VTK format.
>
>
> 3)  Execute again FastMarchingImageFilter
>
>     You may want to update your CVS version of ITK
>     (if you are using one.)
>
>     Some recent improvement have been made to the
>     FastMarchingLevelSet demo-app in the past days.
>
>     The most significant of these changes is the introduction
>     of a Sigmoid for computing the speed image (a negative
>     exponential was used before). This makes much easier
>     to control the generation of an appropriate speed image.
>     The justification is explained in detail on the document:
>
>     http://www.itk.org/ItkSoftwareGuide.pdf
>     (updated 9 minutes ago  :-)
>
>
> 4)  Load the volume in VTK format, it will take about 30
>     seconds to load. Then, click on the "display" button
>     after "Gradient Magnitude". The gradient computation
>     will take about 30 seconds. A viewer will appear with
>     the gradient magnitude of the volume.
>
>
>     Now click on the "Display" button just after the
>     "Linear + Sigmoid" button. It will take about 10 sec.
>     Another viewer should appear with the result of
>     passing the gradient magnitude through the sigmoid.
>     If you clidck with the mouse on the image you will see
>     intensity values in the lower right corner. Homogeneous
>     regions should have values close to 1.0 and contour regions
>     should have values close to 0.0
>
>     Now click on the "Display" button just below the "Load"
>     button. This will show a viewer with the original input image.
>     By clicking in this image with the mouse you will select
>     seed points. A red pixel is overlayed on top of every seed
>     point you selected.  If you want to clear the list of seed
>     points, there is a button "Clear Seeds" below the FastMarching
>     button.  You don't need many seed for this excercise.
>
>     Just go, for example, to slice 97 and click a seed point in
>     the middle of each one of the ventricles. That should be enough.
>
>     Now, click on the "Time-Crosssing Map" button just after
>    "FastMarching". It will take about 5 seconds to compute the map.
>     A viewer should appear with the result of the time-crossing map.
>     By moving the slider at the right of the viewer you should be
>     able to walk through the slices, and find black regions on the
>     ventricles (around slices 70 to 100),
>
>
>     Finally, click on the "Overlay" button on the top right of
>     the GUI. It will compute the threshold of the time-crosssing map
>     and overlay it in red on top of the input image. You can control
>     the transparency of the overlay with the menu bar option on the
>     viewer:  Click on "Overlay" in the menu bar and then in "Opacity",
>     a small window with a slider will popup. Moving the slider you
>     can change the opacity = (1-tranparency) of the red overlay.
>     If you move now the slice-slider on the right of the viewer you
>     will be able to visit all the slices.
>
>     Time for Coffee !
>
>
>
>     Now, while drinking your coffee, You will notice that the
>     segmentation always falls short on touching the actual border of
>     the ventricles. This is natural in Level Sets and it is mainly
>     due to the width of the contour bands produced by the Gradient
>     Magnitude filter. A smaller sigma could help to get closer to the
>     contour,... but it will never be possible to get to it since a
>     gradient will always have some width.
>
>     In practice it could make sense to just apply a couple of
>     Mathematical Morphology Dilations on the final binary mask.
>     The size of the structurant element should be correlated with the
>     sigma used in the gaussian.
>
>
>
>
>
> 5)  About the version of FLTK... just go with FLTK 1.1.1rc4
>     you can download it from our "related software page"
>
>   http://public.kitware.com/Insight/Web/HTML/DownloadRelatedSoftware.htm
>
>   For windows
>   http://public.kitware.com/Insight/Web/HTML/fltk-1.1.0rc4-source.zip
>
>   For Unix
>   http://public.kitware.com/Insight/Web/HTML/fltk-1.1.0rc4-source.tar.gz
>
>   It is not the latest FLTK version, (and that's why we like it :-)
>
>
>
> -------------------
>
>
>
>    Please let us know if you find any problem,
>
>
>     Thanks
>
>
>       Luis
>
>
>
>                    Enjoy ITK !
>
>
>
>
> ----------------------------------------------------
>
>
> Hi all,
>    I have tried FastMarchingImageFilter on a 3D image:
>
> $ head image.vtk
> # vtk DataFile Version 3.0
> vtk output
> ASCII
> DATASET STRUCTURED_POINTS
> DIMENSIONS 512 64 512
> SPACING -0.878906 -2.10938 -0.878906
> ORIGIN 222.035 78.857 231.947
> CELL_DATA 16450623
> POINT_DATA 16777216
> SCALARS scalars short
>
> I load it ok. I then press 'Gradient Magnitude' (default paramater 1.2).
> And when I press 'Dsiplay', it segafults.
>
> Here is the backtrace of gdb:
>
> [malat@localhost Bin]$ gdb ./FastMarchingLevelSet
> GNU gdb Red Hat Linux (5.1.90CVS-5)
> Copyright 2002 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and 
> you are
> welcome to change it and/or distribute copies of it under certain
> conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for 
> details.
> This GDB was configured as "i386-redhat-linux"...
> (gdb) run
> Starting program: /home/malat/Kitware/InsightBin/Bin/FastMarchingLevelSet
> [New Thread 1024 (LWP 7125)]
> [New Thread 2049 (LWP 7140)]
> [New Thread 1026 (LWP 7141)]
>
> Program received signal SIGABRT, Aborted.
> [Switching to Thread 1024 (LWP 7125)]
> 0x42029241 in kill () from /lib/i686/libc.so.6
> (gdb) bt
> #0  0x42029241 in kill () from /lib/i686/libc.so.6
> #1  0x40039c4b in raise () from /lib/i686/libpthread.so.0
> #2  0x4202a7d2 in abort () from /lib/i686/libc.so.6
> #3  0x412e8fab in __default_terminate () at ../../gcc/libgcc2.c:-1
> #4  0x412e8fca in __terminate () from /usr/local/lib/libfltk.so.1.1
> #5  0x412e9d05 in throw_helper (eh=0x811cb80, pc=0x4128375c,
> my_udata=0xbfffec30, offset_p=0xbfffec2c)
>    from /usr/local/lib/libfltk.so.1.1
> #6  0x412e9fff in __rethrow (index=0x80ba474) from
> /usr/local/lib/libfltk.so.1.1
> #7  0x0807439c in
> itk::GradientMagnitudeRecursiveGaussianImageFilter<itk::Image<float, 3>,
> itk::Image<float, 3> >::GenerateData (this=0x80cb2f0) at
> /home/malat/Kitware/Insight/Code/Common/itkSmartPointer.h:74
> #8  0x403941f1 in itk::ProcessObject::UpdateOutputData ()
>    from /home/malat/Kitware/InsightBin/Lib/libITKCommon.so
> #9  0x4037320b in itk::DataObject::UpdateOutputData () from
> /home/malat/Kitware/InsightBin/Lib/libITKCommon.so
> #10 0x40372d7e in itk::DataObject::Update () from
> /home/malat/Kitware/InsightBin/Lib/libITKCommon.so
> #11 0x40393773 in itk::ProcessObject::Update () from
> /home/malat/Kitware/InsightBin/Lib/libITKCommon.so
> #12 0x08066976 in FastMarchingLevelSetBase::ComputeGradientMagnitude
> (this=0x80c90d0)
>     at /home/malat/Kitware/Insight/Code/Common/itkSmartPointer.h:79
> #13 0x08063ecf in FastMarchingLevelSetGUI::cb_Gradient (o=0x80d3818, 
> v=0x0)
>     at
> /home/malat/Kitware/InsightBin/Applications/FastMarchingLevelSet/FastMarchingLevelSetGUI.cxx:69
> #14 0x4128375d in Fl_Widget::do_callback (this=0x80d3818) at
> ../FL/Fl_Widget.H:179
> #15 0x4128b62d in Fl_Button::handle (this=0x80d3818, event=2) at
> Fl_Button.cxx:101
> #16 0x4128235a in send (event=2, to=0x80d3818, window=0x80d2c50) at
> Fl.cxx:531
> #17 0x412826dd in Fl::handle (event=2, window=0x80d2c50) at Fl.cxx:606
> #18 0x412d7165 in fl_handle (xevent=@0xbffff430) at Fl_x.cxx:884
> #19 0x412d549b in do_queued_events () at Fl_x.cxx:170
> #20 0x412d58d3 in fd_callback () at Fl_x.cxx:287
> #21 0x412d57e0 in fl_wait (time_to_wait=1e+20) at Fl_x.cxx:236
> #22 0x4128190b in Fl::wait (time_to_wait=1e+20) at Fl.cxx:273
> #23 0x4128194e in Fl::run () at Fl.cxx:280
> #24 0x08099dae in main ()
>     at
> /home/malat/Kitware/Insight/Applications/FastMarchingLevelSet/FastMarchingLevelSet.cxx:486
> #25 0x42017499 in __libc_start_main () from /lib/i686/libc.so.6
> (gdb) The program is running.  Exit anyway? (y or n) y
>
>
>
> Any idea ?
>
> Thanks a lot,
> Mathieu
> Ps: By the way ldd seems ok:
> [malat@localhost Bin]$ ldd ./FastMarchingLevelSet
>         libpthread.so.0 => /lib/i686/libpthread.so.0 (0x40031000)
>         libdl.so.2 => /lib/libdl.so.2 (0x40046000)
>         libITKAlgorithms.so => 
> /home/malat/Kitware/InsightBin/Lib/libITKAlgorithms.so (0x40049000)
>         libVXLNumerics.so => 
> /home/malat/Kitware/InsightBin/Lib/libVXLNumerics.so (0x40063000)
>         libITKCommon.so => 
> /home/malat/Kitware/InsightBin/Lib/libITKCommon.so (0x40334000)
>         libITKBasicFilters.so => 
> /home/malat/Kitware/InsightBin/Lib/libITKBasicFilters.so (0x403c4000)
>         libITKNumerics.so => 
> /home/malat/Kitware/InsightBin/Lib/libITKNumerics.so (0x403ca000)
>         libITKIO.so => /home/malat/Kitware/InsightBin/Lib/libITKIO.so
> (0x40413000)
>         libITKFltkImageViewer.so => 
> /home/malat/Kitware/InsightBin/Lib/libITKFltkImageViewer.so (0x40495000)
>         libITKVtkFltk.so => 
> /home/malat/Kitware/InsightBin/Lib/libITKVtkFltk.so (0x404d1000)
>         libvtkRendering.so => 
> /home/malat/Kitware/VTKBin/Lib/libvtkRendering.so (0x404d8000)
>         libvtkGraphics.so => 
> /home/malat/Kitware/VTKBin/Lib/libvtkGraphics.so (0x4071b000)
>         libvtkHybrid.so => 
> /home/malat/Kitware/VTKBin/Lib/libvtkHybrid.so (0x409c0000)
>         libvtkImaging.so => 
> /home/malat/Kitware/VTKBin/Lib/libvtkImaging.so (0x40b3c000)
>         libvtkIO.so => /home/malat/Kitware/VTKBin/Lib/libvtkIO.so
> (0x40ddd000)
>         libvtkFiltering.so => 
> /home/malat/Kitware/VTKBin/Lib/libvtkFiltering.so (0x40fed000)
>         libvtkCommon.so => 
> /home/malat/Kitware/VTKBin/Lib/libvtkCommon.so (0x4105f000)
>         libfltk.so.1.1 => /usr/local/lib/libfltk.so.1.1 (0x4125a000)
>         libfltk_gl.so.1.1 => /usr/local/lib/libfltk_gl.so.1.1 
> (0x412fa000)
>         libfltk_forms.so.1.1 => /usr/local/lib/libfltk_forms.so.1.1
> (0x4130d000)
>         libfltk_images.so.1.1 => /usr/local/lib/libfltk_images.so.1.1
> (0x4131d000)
>         libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x4132e000)
>         libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x41403000)
>         libGLU.so.1 => /usr/X11R6/lib/libGLU.so.1 (0x41410000)
>         libGL.so.1 => /usr/lib/libGL.so.1 (0x4148b000)
>         libitkpng.so => /home/malat/Kitware/InsightBin/Lib/libitkpng.so
> (0x414d9000)
>         libitkzlib.so => 
> /home/malat/Kitware/InsightBin/Lib/libitkzlib.so (0x41501000)
>         libITKMetaIO.so => 
> /home/malat/Kitware/InsightBin/Lib/libITKMetaIO.so (0x41512000)
>         libDICOMParser.so => 
> /home/malat/Kitware/InsightBin/Lib/libDICOMParser.so (0x41547000)
>         libITKGlut.so => 
> /home/malat/Kitware/InsightBin/Lib/libITKGlut.so (0x4156e000)
>         libglut.so.3 => /usr/lib/libglut.so.3 (0x41572000)
>         libXmu.so.6 => /usr/X11R6/lib/libXmu.so.6 (0x415a6000)
>         libXi.so.6 => /usr/X11R6/lib/libXi.so.6 (0x415bb000)
>         libvtkftgl.so => /home/malat/Kitware/VTKBin/Lib/libvtkftgl.so
> (0x415c3000)
>         libvtkfreetype.so => 
> /home/malat/Kitware/VTKBin/Lib/libvtkfreetype.so (0x415cc000)
>         libXt.so.6 => /usr/X11R6/lib/libXt.so.6 (0x4160e000)
>         libvtkpng.so => /home/malat/Kitware/VTKBin/Lib/libvtkpng.so
> (0x4165a000)
>         libvtktiff.so => /home/malat/Kitware/VTKBin/Lib/libvtktiff.so
> (0x41685000)
>         libvtkzlib.so => /home/malat/Kitware/VTKBin/Lib/libvtkzlib.so
> (0x416d6000)
>         libvtkjpeg.so => /home/malat/Kitware/VTKBin/Lib/libvtkjpeg.so
> (0x416e7000)
>         libvtkexpat.so => /home/malat/Kitware/VTKBin/Lib/libvtkexpat.so
> (0x4170d000)
>         libstdc++.so.5 => /usr/local/lib/libstdc++.so.5 (0x4173a000)
>         libm.so.6 => /lib/i686/libm.so.6 (0x417ea000)
>         libc.so.6 => /lib/i686/libc.so.6 (0x42000000)
>         libstdc++-libc6.2-2.so.3 => /usr/lib/libstdc++-libc6.2-2.so.3
> (0x4180d000)
>         libXft.so.1 => /usr/X11R6/lib/libXft.so.1 (0x41850000)
>         libpng.so.2 => /usr/lib/libpng.so.2 (0x4187a000)
>         libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0x4189b000)
>         libz.so.1 => /usr/lib/libz.so.1 (0x418ba000)
>         libGLcore.so.1 => /usr/lib/libGLcore.so.1 (0x418c8000)
>         libSM.so.6 => /usr/X11R6/lib/libSM.so.6 (0x41d5a000)
>         libICE.so.6 => /usr/X11R6/lib/libICE.so.6 (0x41d62000)
>         libgcc_s.so.1 => /usr/local/lib/libgcc_s.so.1 (0x41d79000)
>         /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
>         libXrender.so.1 => /usr/X11R6/lib/libXrender.so.1 (0x41d82000)
>         libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x41d87000)
>
>
> And finally (if someone reach that point), I am not sure about which
> fltk verion I need:
> According to the ITK FAQ:
> http://www.itk.org/cgi-bin/InsightFAQ/InsightFAQ?query=fltk&querytype=simple&casefold=yes&req=search
> I need rc6.
> But according to http://itk.org/HTML/DownloadRelatedSoftware.htm
> The only one available is rc4
>
> Thanks again !
> mathieu
>
>
>
>
>
>
>