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

Dan Mueller dan.muel at gmail.com
Tue Aug 26 04:42:36 EDT 2008


Hi Sara,

Did you compile the code in Release mode? Compiling in Release mode
(as opposed to Debug mode) significantly improves performance...

2008/8/26 sara meghellati <sara_meghellati at yahoo.fr>:
> Dear Luis,
> I would like to thank you and all the other itk members who have replied me
> regarding my question.
> I have gave a try with your code. my CPU is Intel core 2, 2.41 Ghz and 2 Gb
> of Ram. it takes nearly 34 minutes. So I have tried my code, its working and
> it takes also nearly 34 minutes. I used 0.001 for threshold and 0.1 for the
> level parameter.
> Sara
> Best regards
>
> --- En date de : Ven 22.8.08, Luis Ibanez <luis.ibanez at kitware.com> a
> écrit :
>
> De: Luis Ibanez <luis.ibanez at kitware.com>
> Objet: Re: [Insight-users] nobody could answer me ? Fw : Please help:problem
> with wathershed segmentation applied to 3D grayscale Image
> À: sara_meghellati at yahoo.fr
> Cc: "insight itk" <insight-users at itk.org>
> Date: Vendredi 22 Août 2008, 18h59
>
>
> Hi Sara,
>
> Thanks for your detailed question regarding Watersheds.
>
>
> Please take a look at the attached code.
>
> It process the image "Patient01" from
>
>         http://public.kitware.com/pub/itk/Data/LiverTumor/.
>
> in a time of
>
>                     4 minutes 38 seconds.
>
> This was profiled in an QuadCore Intel Xeon 2.66 Ghz. (with 16Gb RAM).
> (although the process uses only one of the cores)
>
> Note that the process peaks 1Gb of memory allocation when it is running.
>
> Depending on the configuration of your system, it may be that the program
> started swapping memory at some point.
>
> Please give a try at the attached code and let us know what you find.
>
>
>      Regards,
>
>
>           Luis
>
>
> -----------------------------------------------------------------------------------------------------------------------------------
> On Fri, Aug 22, 2008 at 11:19 AM, sara meghellati <sara_meghellati at yahoo.fr>
> wrote:
>>
>> 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 provided
>>
>> in 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;
>
>
>
> }
>
> Thanks
>
> Sara


More information about the Insight-users mailing list