[Insight-users] nobody could answer me ? Fw : Please help:problem with wathershed segmentation applied to 3D grayscale Image
Luis Ibanez
luis.ibanez at kitware.com
Fri Aug 22 12:59:06 EDT 2008
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
>
>
> ------------------------------
> Envoyé avec Yahoo! Mail<http://us.rd.yahoo.com/mailuk/taglines/isp/control/*http://us.rd.yahoo.com/evt=52423/*http://fr.docs.yahoo.com/mail/overview/index.html>
> .
> Une boite mail plus intelligente.
>
> _______________________________________________
> Insight-users mailing listInsight-users at itk.orghttp://www.itk.org/mailman/listinfo/insight-users
>
>
> ------------------------------
> Envoyé avec Yahoo! Mail<http://us.rd.yahoo.com/mailuk/taglines/isp/control/*http://us.rd.yahoo.com/evt=52423/*http://fr.docs.yahoo.com/mail/overview/index.html>
> .
> Une boite mail plus intelligente.
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080822/5a749f68/attachment-0001.htm>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Watershed3D.cxx
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080822/5a749f68/attachment.txt>
More information about the Insight-users
mailing list