[Insight-users] Segmentation with Watersheds doesn't produce results

Joshua Cates cates at sci.utah.edu
Thu Jan 27 13:08:08 EST 2005


Hi Sotiris,

I suggest running your images through the examples given in the Itk
software guide first to get a sense of what is possible with this filter.
Also note that if you SetLevel(1.0) on the watershed filter, you will get
a single segmented region on the output (a constant valued image).  See 
the software guide available from www.itk.org.

The GradientMagnitude filter for scalar images (e.g. CT) has no principal
component analysis setting.  This setting only applies to vector-valued 
data such as color images.

Josh.

______________________________
 Josh Cates			
 Scientific Computing and Imaging Institute
 University of Utah
 http://www.sci.utah.edu/~cates


On Thu, 27 Jan 2005, Sotiris Dimopoulos wrote:

> Hi!
> I use watershed for the segmentation of a ct slice
> (of a simple bone) which is in jpeg format(i have it
> in dicom too), and in the
> vtk window in which i see my results...i get
> nothing...( as if my program found nothing to
> segment).
> The code appears to be flawles during the building
> procedure.
> 
> I,m also a bit confused with the parameters..For
> example what parameter do i set in the function
> SetUsePrincipleComponents() of the
> GradientMagnitudeImageFilter class??
> How do i define the SetLevel(),SetThreshhold()
> function s of the WatershedImageFilter class? By trial
> and error?
> 
> I'm sending tyou the code in case something else goes
> wrong...
> 
> Many Thanks in advance
> 
> Sotiris
> 
> 
> int main( int argc, char *argv[])
> {
>   
> 
>   //  We declare the image types 
>   
>   typedef unsigned char          PixelType;
>   const unsigned int             Dimension1 = 2;
> 
>   typedef itk::Image< PixelType, Dimension1 >  
> ImageType;
> 
> 
>   typedef   float           InternalPixelType;
>    const     unsigned int    Dimension = 2;
>   typedef itk::Image< InternalPixelType, Dimension > 
> InternalImageType;
>  
> 
>   typedef unsigned char OutputPixelType;
>   typedef itk::Image< OutputPixelType, Dimension >
> OutputImageType;
>   
>                         
> 
>   typedef  itk::ImageFileReader< InternalImageType >
> ReaderType;
>   
>   ReaderType::Pointer reader = ReaderType::New();
>  
>   reader->SetFileName( "C:/Documents and
> Settings/sotiris/Desktop/OSTA/osta
> 3,5/JPEG/Img0108.jpg" );
>  
>    
> 
> //declare the filters
> 
>   typedef
> itk::GradientAnisotropicDiffusionImageFilter<InternalImageType,
>     InternalImageType>  DiffusionFilterType;
>   typedef
> itk::GradientMagnitudeImageFilter<InternalImageType,InternalImageType>
>     GradientMagnitudeFilterType; 
>   typedef itk::WatershedImageFilter<InternalImageType>
> WatershedFilterType;
>   typedef itk::CastImageFilter< InternalImageType,
> OutputImageType >
>     CastingFilterType;
>   
>   
> 
>    DiffusionFilterType::Pointer diffusion =
> DiffusionFilterType::New();
>   diffusion->SetNumberOfIterations( 5.0 );
>   diffusion->SetConductanceParameter( 9.0 );
>   diffusion->SetTimeStep(0.0625);
>   
> 
>   GradientMagnitudeFilterType::Pointer gradient =
> GradientMagnitudeFilterType::New();
>   //gradient->SetUsePrincipleComponents(????????????);
>   
> 
>   WatershedFilterType::Pointer watershed =
> WatershedFilterType::New();
>   watershed->SetLevel( 1) ;
>   watershed->SetThreshold( 0 );
> 
>     CastingFilterType::Pointer caster =
> CastingFilterType::New();
> 
>   //  Now it is time to connect a simple, linear
> pipeline. A file reader is
>   //  added at the beginning of the pipeline and a
> cast filter 
>   //  is added at the end. The cast filter is required
> to convert
>   //  \code{float} pixel types to integer types since
> only a few image file
>   //  formats support \code{float} types.
> 
>   diffusion->SetInput( reader->GetOutput() );
>   gradient->SetInput( diffusion->GetOutput() );
>   watershed->SetInput( gradient->GetOutput() );
>  
> caster->SetInput((InternalImageType*)watershed->GetOutput()
> );
> 
> 
>   
>     //Exit the itk pipeline and enter the vtk pipeline
> 
>    typedef itk::ImageToVTKImageFilter<ImageType>
> ConnectorType;   
>    
>    ConnectorType::Pointer connector=
> ConnectorType::New();
> 
>    connector->SetInput(caster ->GetOutput() );
> 
> 
>     // Create the Image Mapper
> 
>     vtkImageMapper *mapper = vtkImageMapper::New();
>          mapper -> SetInput(connector -> GetOutput());
>          mapper -> SetColorWindow(255);
>          mapper -> SetColorLevel(128);
>         
>      // Create the Actor
> 
>     vtkActor2D *actor = vtkActor2D::New();
>          actor -> SetMapper(mapper);
> 
> 
>      // Create the Rendering Window for viewing what
> you've done
> 
>     vtkRenderer *imager = vtkRenderer::New();
>            imager -> AddActor2D(actor);
>         
> 
>   
>     vtkRenderWindow *imgWin = vtkRenderWindow::New();
>            imgWin -> AddRenderer(imager);
>            
>             
> 
>     
>     vtkRenderWindowInteractor *iren =
> vtkRenderWindowInteractor::New();
>            iren -> SetRenderWindow(imgWin);
>            
>            imager->SetBackground(1,1,1);
>            imgWin->SetSize(550,550);
> 
> 
>     imgWin -> Render();
>     iren->Start();
> 
>     
>   // Clean up
>           
>          mapper -> Delete();
>      actor -> Delete();
>  imager -> Delete();
>  imgWin -> Delete();
>          iren -> Delete();
>  
> 
> 
> 
> 
>   return 0;
> }
> 
> ____________________________________________________________
> Do You Yahoo!?
> ÁðïêôÞóôå ôç äùñåÜí @yahoo.gr äéåýèõíóç óáò óôï http://www.otenet.gr
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 



More information about the Insight-users mailing list