[Insight-users] nobody could answer me ? Fw : Please help:problem with wathershed segmentation applied to 3D grayscale Image

sara meghellati sara_meghellati at yahoo.fr
Fri Aug 22 11:19:55 EDT 2008


I'm sending again my questions as nobody have answered me. 

--- En date de : Ven 22.8.08, sara meghellati <sara_meghellati at yahoo.fr> a écrit :

De: sara meghellati <sara_meghellati at yahoo.fr>
Objet: [Insight-users] Please help:problem with wathershed segmentation applied to 3D grayscale Image
À: "insight itk" <insight-users at itk.org>
Date: Vendredi 22 Août 2008, 13h48






Dear itk experts,I’m segmenting a volume (3D grayscale image) using watershed method inspired from the WatershedSegmentation1 (2D RGB image as input)example provided within itk.My code is well working for 2D grayscale images but when I change the dimension to 3, the code
 still running as it get stuck in a loop!! I wait for more than 18min but no results!! Is it normal that this kind of segmentation takes age to give the result in 3d image or there is some thing wrong with my code? Please could you help me on that? Also, how can I follow the progress of the code?I pass my code bellow. In this example I used the 3D data providedin http://public.kitware.com/pub/itk/Data/LiverTumor/.#include <iostream>
#include "itkImage.h" 
#include "itkGradientAnisotropicDiffusionImageFilter.h" 
#include "itkGradientMagnitudeImageFilter.h" 
#include "itkWatershedImageFilter.h" 
#include "itkImageFileReader.h" 
#include "itkImageFileWriter.h" 
#include "itkVectorCastImageFilter.h" 
#include "itkUnaryFunctorImageFilter.h" 
#include "itkScalarToRGBPixelFunctor.h" 
  
#include "itkVTKImageExport.h" 
#include "itkVTKImageImport.h" 
  
#include "vtkImageData.h" 
#include "vtkImageImport.h" 
#include "vtkImageExport.h" 
#include "vtkImageActor.h" 
#include "vtkRenderer.h" 
#include "vtkRenderWindow.h" 
#include "vtkRenderWindowInteractor.h" 
#include "vtkInteractorStyleTrackballCamera.h" 
#include "vtkImageShiftScale.h" 
  
// This function will connect the given itk::VTKImageExport filter to the given vtkImageImport filter. 
template <typename ITK_Exporter, typename VTK_Importer> 
void ConnectPipelines(ITK_Exporter exporter, VTK_Importer* importer) 
{ 
  importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback()); 
  importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback()); 
  importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback()); 
  importer->SetSpacingCallback(exporter->GetSpacingCallback()); 
  importer->SetOriginCallback(exporter->GetOriginCallback()); 
  importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback()); 
  importer->SetNumberOfComponentsCallback(exporter->GetNumberOfComponentsCallback()); 
  importer->SetPropagateUpdateExtentCallback(exporter->GetPropagateUpdateExtentCallback()); 
  importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback()); 
  importer->SetDataExtentCallback(exporter->GetDataExtentCallback()); 
  importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback()); 
  importer->SetCallbackUserData(exporter->GetCallbackUserData()); 
} 
  
int main( ) 
{  
      typedef itk::Image<float, 3>           ImageType; 
      typedef itk::Image<unsigned long, 3>   LabeledImageType; 
      typedef itk::Image<float, 3>           ScalarImageType; 
      // for visualization purposes 
      typedef itk::RGBPixel<unsigned char>   RGBPixelType; 
      typedef itk::Image<RGBPixelType, 3>    RGBImageType; 
  
      typedef itk::ImageFileReader<ImageType> FileReaderType; 
      typedef itk::GradientAnisotropicDiffusionImageFilter<ImageType,   ImageType>  DiffusionFilterType; 
      typedef itk::GradientMagnitudeImageFilter<ImageType,ImageType>    GradientMagnitudeFilterType; 
      typedef itk::WatershedImageFilter<ScalarImageType> WatershedFilterType; 
      typedef itk::ImageFileWriter<RGBImageType> FileWriterType; 
  
      FileReaderType::Pointer reader = FileReaderType::New 
      reader->SetFileName( "c:/images/3DImages/Patient01.mhd"  ); 
      //reader->SetFileName("c:/Images/BrainProtonDensitySlice.png"); 
  
      DiffusionFilterType::Pointer diffusion = DiffusionFilterType::New(); 
      diffusion->SetNumberOfIterations( atoi("10") ); 
      diffusion->SetConductanceParameter( atof("2.0") ); 
      diffusion->SetTimeStep(0.0625); 
  
      GradientMagnitudeFilterType::Pointer gradient = GradientMagnitudeFilterType::New(); 
      
      WatershedFilterType::Pointer watershed = WatershedFilterType::New(); 
      watershed->SetLevel( atof("0.15") );       
      watershed->SetThreshold( atof("0.001") );  
      typedef itk::Functor::ScalarToRGBPixelFunctor<unsigned long>    ColorMapFunctorType; 
      typedef itk::UnaryFunctorImageFilter<LabeledImageType,    RGBImageType, ColorMapFunctorType> ColorMapFilterType; 
      ColorMapFilterType::Pointer colormapper = ColorMapFilterType::New(); 
  
      FileWriterType::Pointer writer = FileWriterType::New(); 
      writer->SetFileName("c:/Images/WatershedSegImg.mhd"); 
  
      diffusion->SetInput(reader->GetOutput()); 
      gradient->SetInput(diffusion->GetOutput()); 
      watershed->SetInput(gradient->GetOutput()); 
      colormapper->SetInput(watershed->GetOutput()); 
      writer->SetInput(colormapper->GetOutput()); 
      writer->Update(); 
  
try 
    { 
            writer->Update();       
    } 
  catch (itk::ExceptionObject &e) 
    { 
            std::cerr << e << std::endl; 
    } 
    
  return 0; 
  
}ThanksSara 


Envoyé avec Yahoo! Mail.
Une boite mail plus intelligente. _______________________________________________
Insight-users mailing list
Insight-users at itk.org
http://www.itk.org/mailman/listinfo/insight-users



      _____________________________________________________________________________ 
Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080822/a5411403/attachment-0001.htm>


More information about the Insight-users mailing list