[Insight-users] 3D Fastmarching segmentation!

Luis Ibanez luis.ibanez at kitware.com
Mon, 12 Apr 2004 20:55:38 -0400


Hi Xujf,

There is something confusing about your description of the
output produced by the GradientMagnitudeRecursiveGaussian
filter. You seem to indicate that the image has zero values
close to edges and almost 1.0 in other places.  This is unlikely
in a gradient magnitude image. What it is to expect from such
an image is to have high values on the edges of the original
image and very low values elsewhere.  This is in fact the reason
why you need the Sigmoid filter, since you need to invert the
intensities of the GradientMagnitude in order to get low values
in the edges and high values in the homogeneous regions.

Please double-check the output of the GradientMagnitude filter.
Then you can play with the parameters of the Sigmoid until you
obtain as output something that looks like the speed images
presented in the SoftwareGuide.

Note that the Alpha parameter of the Sigmoid must be negative
in order to produce the inversed image (in intensity) that you
need as speed image for the FastMarching filter.



Regards,


   Luis



-------------
xujf wrote:
> Hi,Luis:
>    thanks for your help.
>    According to your advice,I look at the speed image\'s value which is output of sigmoid filter.in order to see the value, vtkImageDataGeometryFilter is used to  get some slice of  the 3D image. I find that the speed image is not good,so I know why I can\'t get the result of fastmarching.
>    then I look at the image which is output of GradientMagnitudeRecursiveGaussianImageFilter.
> this image is very good:looks almost like a binary image,but have zero values close to edges and have values close to1.0 in the regions where the front will propagate continously.so the input of sigmid filter is good.
>    as above:the input of sigmoid is good ,however the output of sigmoid is not good.I think maybe I make some mistakes when I use itkSigmoidImageFilter.
>   If I use the itkSigmoidImageFilter correctly,Is there any other place I make mistakes?
> 
> Best Regards!
> xujf
>   
> 
> ----- Original Message -----
> From: Luis Ibanez <luis.ibanez at kitware.com>
> To: xujf at sjtu.edu.cn
> Cc: insight-users at itk.org
> Subject: Re: [Insight-users] 3D Fastmarching segmentation!
> 
> 
> Hi Xujf,
> 
> You shouldn\'t invoke the "SetSpeedConstant()" method
> if you are at the same time providing an input speed
> image.
> 
> The "SetSpeedConstant()" method is intended to be used
> when you don\'t have an input speed image and want the
> front to propagate at constant speed. This is usually
> done when you want to use FastMarching as a Distance
> Map calculator.
> 
> Please look at the documentation of this method in
> the Doxygen page of the FastMarchingImageFilter.
> http://www.itk.org/Insight/Doxygen/html/classitk_1_1FastMarchingImageFilter.html
> 
> --
> 
> It is very likely that the reason why you are not
> getting any segmentation is related to the image
> that is being passed as input to the FastMarching
> filter. Than is, the output of the Sigmoid filter.
> Please save this image in a file, or connect it to
> a vtkImageViewer in order to look at its values.
> 
> The speed image should look almost like a binary image,
> and should have almost zero values close to the edges
> where you want the segmentation surface to stop, and
> should have values close to 1.0 in the regions where
> you want the front to propagate continously.  Note that
> you can change this value of 1.0 (as the max speed) by
> using the method "SetNormalizationFactor()" in the
> FastMarching filter (again, look at Doxygen doc for
> a description of this method).
> 
> 
> The key for a succesful application of FastMarching
> is to provide an apropriate Speed image as input. That
> is the *only* source of information that FastMarching
> has from your actual original image.  The result of
> FastMarching will be as good (or as bad) as your speed
> image is.
> 
> -------------
> xujf wrote:
> 
> 
>>Hi,all:
>>   I use itkFastMarchingImageFilter to implement the segmentation. I can do the segmentation well in 2D image,
>>the result image is very nice. I change my 2D segmentation code a little in order to get the 3D segmentation.
> 
> 
>>------------------------------------------------------------------------
>>
>>import sys,os
>>import paths
>>import InsightToolkit as itk
>>from vtkMINCReader  import *
>>import ConnectVTKITK as connect
>>
>>reader=vtkMINCReader()
>>vtkexport=vtkImageExport()
>>reader.SetFileName("E:/atamai/2003-01-27/atamai/examplesPmw/sbrain.mnc")
>>
>>cast=vtkImageCast()
>>cast.SetOutputScalarTypeToFloat()
>>cast.SetInput(reader.GetOutput())
>>
>>vtkexport.SetInput(cast.GetOutput())
>>
>>itkimport=itk.itkVTKImageImportF3_New()
>>
>>connect.ConnectVTKToITKF3(vtkexport,itkimport.GetPointer())
>>
>>itkcurfilter=itk.itkCurvatureAnisotropicDiffusionImageFilterF3F3_New()
>>itkbinfilter=itk.itkBinaryThresholdImageFilterF3US3_New()
>>itkgradfilter=itk.itkGradientMagnitudeRecursiveGaussianImageFilterF3F3_New()
>>itksigfilter=itk.itkSigmoidImageFilterF3F3_New()
>>itkfastmarchingfilter=itk.itkFastMarchingImageFilterF3F3_New()
>>
>>itkcurfilter.SetTimeStep( 0.0625);
>>itkcurfilter.SetNumberOfIterations(  5 );
>>itkcurfilter.SetConductanceParameter( 9.0 );
>>
>>itksigfilter.SetOutputMinimum(0.0)
>>itksigfilter.SetOutputMaximum(1.0)
>>itksigfilter.SetAlpha(-1.0)
>>itksigfilter.SetBeta(5.0)
>>
>>itkgradfilter.SetSigma(1.0)  
>>seeds=itk.itkNodeContainerF3_New()
>>
>>seedPosition=itk.itkIndex3()
>>seedPosition.SetElement(0,100)
>>seedPosition.SetElement(1,100)
>>seedPosition.SetElement(2,100)
>>
>>node=itk.itkLevelSetNodeF3()
>>node.SetValue(-10)
>>node.SetIndex(seedPosition)
>>seeds.Initialize()
>>seeds.InsertElement(0,node)
>>itkfastmarchingfilter.SetTrialPoints(seeds.GetPointer())
>>itkfastmarchingfilter.SetSpeedConstant(1.0)
>>itkfastmarchingfilter.SetStoppingValue(80.0)
>>
>>itkbinfilter.SetLowerThreshold(0.0)
>>itkbinfilter.SetUpperThreshold(1.0 )
>>itkbinfilter.SetOutsideValue( 0  )
>>itkbinfilter.SetInsideValue(65535)
>>  
>>itkcurfilter.SetInput(itkimport.GetOutput())
>>itkgradfilter.SetInput(itkcurfilter.GetOutput())
>>itksigfilter.SetInput(itkgradfilter.GetOutput())
>>itkfastmarchingfilter.SetInput(itksigfilter.GetOutput())
>>itkbinfilter.SetInput(itkfastmarchingfilter.GetOutput())
>>
>>vtkimport=vtkImageImport()
>>itkexport=itk.itkVTKImageExportUS3_New()
>>itkexport.SetInput(itkbinfilter.GetOutput())
>>
>>connect.ConnectITKUS3ToVTK(itkexport.GetPointer(),vtkimport)
> 
> 
>>lut=vtkLookupTable()
>>lut.SetTableRange(0,2000)
>>lut.SetSaturationRange(0,0)
>>lut.SetHueRange(0,0)
>>lut.SetValueRange(0,1)
>>
>>data=vtkimport.GetOutput()
>>vtkimport.Update()
>>
>>filter=vtkImageDataGeometryFilter()
>>filter.SetInput(data)
>>filter.SetExtent(0,180,100,100,0,180)# only see a slice of the 3D image
>>#print data.GetExtent()
>>mapper=vtkPolyDataMapper()
>>mapper.SetInput(filter.GetOutput())
>>mapper.SetLookupTable(lut)
>>mapper.ScalarVisibilityOn()
>>mapper.SetScalarRange(0,100)
>>actor=vtkActor()
>>actor.SetMapper(mapper)
>>
>>ren = vtkRenderer()
>>renWin = vtkRenderWindow()
>>renWin.AddRenderer(ren)
>>iren = vtkRenderWindowInteractor()
>>iren.SetRenderWindow(renWin)
>>ren.AddActor(actor)
>>
>>iren.Initialize()
>>renWin.Render()
>>iren.Start()
> 
>