[vtkusers] [Insight-users] visualization-problem after segmentation and cropping

Yusuf OEZBEK nasil122002 at yahoo.de
Fri May 28 14:43:04 EDT 2010


Hello Luis,

I'm sorry, I have understood you wrong. Change of pixel-type in code does not work. I always get MET_ULONG_LONG. Also, Yes, I work with 64-bit machine.
Am I doing something wrong in code?

 typedef float InternalPixelType;
 typedef unsigned long OutputPixelType;
 const unsigned int Dimension = 3;

 typedef itk::OrientedImage< InternalPixelType, Dimension >    ImageType;

 typedef itk::ImageSeriesReader< ImageType >   ReaderType;
 ReaderType::Pointer reader = ReaderType::New();

 typedef itk::GDCMImageIO     ImageIOType;
 ImageIOType::Pointer dicomIO = ImageIOType::New();

 reader->SetImageIO( dicomIO );

 typedef itk::GDCMSeriesFileNames NamesGeneratorType;
 NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();

 nameGenerator->SetUseSeriesDetails( true );
 nameGenerator->AddSeriesRestriction("0008|0021" );

 nameGenerator->SetDirectory( selectedDirectory);

 typedef std::vector< std::string >    SeriesIdContainer;
   
 const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();
   
 SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();
 SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();
 while( seriesItr != seriesEnd )
     {
     seriesItr++;
     }

 std::string seriesIdentifier;

 seriesIdentifier = seriesUID.begin()->c_str();

 typedef std::vector< std::string >   FileNamesContainer;
 FileNamesContainer fileNames;

 fileNames = nameGenerator->GetFileNames( seriesIdentifier );

 reader->SetFileNames( fileNames );
 reader->Update();
 
 reader->GetOutput()->Print( std::cout );

 typedef itk::Image< InternalPixelType, Dimension > InternalImageType;
 typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
  
 typedef itk::GradientMagnitudeRecursiveGaussianImageFilter<InternalImageType,InternalImageType> GradientMagnitudeFilterType;
 GradientMagnitudeFilterType::Pointer gradienMagnitudeFilter = GradientMagnitudeFilterType::New();
 gradienMagnitudeFilter->SetInput( reader->GetOutput() );
 gradienMagnitudeFilter->SetSigma( 1.0 );
 
 typedef itk::WatershedImageFilter<InternalImageType> WatershedFilterType;
 WatershedFilterType::Pointer watershedFilter = WatershedFilterType::New();
 watershedFilter->SetInput(gradienMagnitudeFilter->GetOutput());
 watershedFilter->SetThreshold(this->sliderThresholdWatershed->value());
 watershedFilter->SetLevel(this->sliderLevelWatershed->value());
// 	typedef WatershedFilterType::OutputImageType  LabeledImageType;
 
 typedef  itk::ImageFileWriter< OutputImageType  > WriterType;
 WriterType::Pointer writer = WriterType::New();
 writer->SetInput( watershedFilter->GetOutput() );
 writer->SetFileName("Watershed.mhd");
 writer->Write();

 typedef itk::VTKImageExport< OutputImageType  > ExportFilter2Type;
 ExportFilter2Type::Pointer itkExporter2 = ExportFilter2Type::New();
     
 itkExporter2->SetInput( watershedFilter->GetOutput() );

 vtkImageImport* vtkImporter2 = vtkImageImport::New();  
 ConnectPipelines(itkExporter2, vtkImporter2);
 
 vtkImporter2->Update();

 this->displayImage3D->show();
 this->displayImage3D->redraw();

 mode3D = vtkInteractorStyleTrackballCamera::New();

 renderer3D = vtkRenderer::New();

 renderWindow3D = vtkRenderWindow::New();
 renderWindow3D->AddRenderer(renderer3D);

 displayImage3D->SetRenderWindow(renderWindow3D);
 displayImage3D->SetInteractorStyle(mode3D);
 displayImage3D->Initialize();

 contourWatershed = vtkContourFilter::New();
 contourWatershed->SetInput( vtkImporter2->GetOutput() );
 contourWatershed->SetValue(-1000, 4096); // edges of a binary image with values 0,255
      
 mapperWatershed = vtkPolyDataMapper::New();
 mapperWatershed->SetInput(contourWatershed->GetOutput());
 mapperWatershed->ScalarVisibilityOff();
 
 propertyWatershed = vtkProperty::New();
 propertyWatershed->SetAmbient(0.3);
 propertyWatershed->SetDiffuse(1.0);
 propertyWatershed->SetSpecular(0.2);
 propertyWatershed->SetSpecularPower(10.0);
 propertyWatershed->SetColor(1 ,1, 1);
 propertyWatershed->SetRepresentationToSurface();
 
 polyActorWatershed  = vtkActor::New();
 polyActorWatershed->SetMapper(mapperWatershed);
 polyActorWatershed->SetProperty(propertyWatershed);
 
 camera3D = vtkCamera::New();
 camera3D->SetViewUp(0, 0, -1);
 camera3D->SetPosition(0, 1, 0);
 camera3D->SetFocalPoint(0, 0, 0);
 camera3D->ComputeViewPlaneNormal();
 camera3D->Azimuth(20);
 
 renderer3D->AddActor(polyActorWatershed);
 renderer3D->SetActiveCamera(camera3D);
 renderer3D->ResetCamera();
 camera3D->Dolly(1.3);
 renderer3D->ResetCameraClippingRange();
 

Thank you.




________________________________
Von: Luis Ibanez <luis.ibanez at kitware.com>
An: Yusuf OEZBEK <nasil122002 at yahoo.de>
CC: ITK Mailinglist <insight-users at itk.org>; VTK Mailinglist <vtkusers at vtk.org>; nasil122002 at gmail.com
Gesendet: Freitag, den 28. Mai 2010, 16:52:20 Uhr
Betreff: Re: [Insight-users] visualization-problem after segmentation and  cropping


Hi Yusuf,


   Manually modifying the pixel type tag in the 
   metaimage header  will not do the trick.

   (in your modified image, the pixel type doesn't
   match the content of the pixel buffer, which 
   explains the distorted appearance of the image).


   My apologies if my instructions were not clear.



   What I suggested you to do, was to change
   the pixel type in your code, and then to run
   the code again.


   Please do so, 
   and let us know what you find.


       Thanks


           Luis   



--------------------------------------------------

On Wed, May 26, 2010 at 9:10 PM, Yusuf OEZBEK <nasil122002 at yahoo.de> wrote:

Hello Luis,
>
>
>
>I have manually converted the pixel type to unsigned long (ElementType = MET_ULONG) in. mhd file and loaded with 3Dslicer. It works but the 3D-image is not correctly displayed. I get as 3D two axial-view side by side. If I visualize it in my program with vtk, then I get purposeful 3D-image.
>
>
>
>
>
>
>Here are the screenshots:
>
>
>Output-Image of watershed on my program (visualized with vtkContourFilter):
>http://www.wopsys.com/bilder/watershed_visualizedwithvtk.png
>
>
>
>
>>Output-Image of watershed on 3DSlicer:
>http://www.wopsys.com/bilder/watershed.JPG
>
>
>
>
>>Output-Image of DicomSeriesReadImageWrite2,
> so before segmentation:
>http://www.wopsys.com/bilder/before_segmentation.png
>
>
>
>
>
>
>Thank you.
>
>
>
________________________________
Von: Luis Ibanez <luis.ibanez at kitware.com>
>An: Yusuf OEZBEK <nasil122002 at yahoo.de>
>CC: ITK Mailinglist <insight-users at itk.org>; VTK Mailinglist <vtkusers at vtk.org>; nasil122002 at gmail.com
>Gesendet: Mittwoch, den 26. Mai 2010, 19:56:18 Uhr
>
>Betreff: Re: [Insight-users] visualization-problem after segmentation and  cropping
>
>
>
>Hi Yusuf,
>
>Excellent.
>
>Thanks for posting the screenshots.
>
>
>They illustrate that the pipeline is working correctly
>up to the output of the region growing filter.
>
>
>You can now focus on getting the Watershed 
>>filter to work correctly by using as output image
>an image of pixel type "unsigned long" and 
>making sure that it doesn't turn into "long long"
>in your 64 bits machine.
>
>Please post the screenshot of the Watershed
>>
>output once you get it to work.
>
>
>    Thanks
>
>
>           Luis
>
>
>-------------------------------------------------------------------
>
>On Tue, May 25, 2010 at 4:14 PM, Yusuf OEZBEK <nasil122002 at yahoo.de> wrote:
>
>Hello Luis,
>>
>>
>>
>>I have the.mhd files loaded with 3DSlicer. Here are the screenshots:
>>
>>
>>Output-Image of Region Growing:
>>http://www.wopsys.com/bilder/regiongrowing_notcropped.JPG
>>http://www.wopsys.com/bilder/regiongrowing_cropped.JPG
>>
>>
>>
>>
>>Output-Image of DicomSeriesReadImageWrite2:
>>http://www.wopsys.com/bilder/DicomSeriesReadImageWrite2.JPG
>>
>>
>>
>>
>>
>>
>>
>>
>>Thanks.
>>
>>
________________________________
 >>Von: Luis Ibanez <luis.ibanez at kitware.com>
>>An: Yusuf OEZBEK <nasil122002 at yahoo.de>
>>CC: ITK Mailinglist <insight-users at itk.org>; VTK Mailinglist <vtkusers at vtk.org>; vtkusers-request at vtk.org; nasil122002 at gmail.com
>>Gesendet: Dienstag, den 25. Mai 2010, 17:00:30 Uhr
>>Betreff: Re: [Insight-users]
>> visualization-problem after segmentation and  cropping
>>
>>
>>Hi Yusuf,
>>
>>
>>When you are debugging a pipeline you should
>>start by verifying that the data has been properly
>>>>loaded in memory, and then you should proceed
>>to check out the output of every intermediate filter
>>in order: from source to final output.
>>
>>
>>Please start by doing the following:
>>
>>
>>    Verify that you succeeded reading the DICOM series.
>>
>>    Simply write the output of the Series reader to
>>    an output file.
>>
>>    This essentially the code that you will see in
>>    the example:
>>
>>
>>    Insight/Examples/IO/
>>        DicomSeriesReadImageWrite2.cxx
>>
>>
>>    Open that file with any visualization software
>>
>>    For example:
>>
>>    1) Paraview. (http://www.paraview.org)  or
>>    2) Slicer, (http://www.slicer.org)  or
>>>>
>>    3) SNAP, (http://sourceforge.net/projects/itk-snap/)  or
>>    4) VV (http://www.creatis.insa-lyon.fr/rio/vv)
>>
>>
>>Please let us know if you manage to do that initial
>>test, (it will be great if you post a screen shot of
>>that output image)
>>
>>and then we will guide you to the next step.
>>
>>
>>
>>    Regards,
>>
>>
>>         Luis
>>
>>
>>--------------------------------------------------
>>On Mon, May 24, 2010 at 10:26 PM, Yusuf OEZBEK <nasil122002 at yahoo.de> wrote:
>>>>
>>> Hello,
>>>
>>>  I have a problem with cut (cropping) and visualization a 3D image, which I
>>> produced by the segmentation-method “watershed and region
>> growing”. In the
>>> beginning I read the DICOM images with itkImageSeriesReader, then I run
>>> watershed or region growing algorithm, in order to connect itk with vtk and
>>> a 3D image produce and for the displaying of segmentation I use
>>>>
>>> vtkContourFilter. After segmentation for cropping the images I use
>>> vtkBoxClipDataSet and vtkDataSetSurfaceFilter, but the result is a black
>>> screen.  When I read the images with vtkDICOMImageReader or
>>>>
>>> itkImageSeriesReader and then segmented with volume rendering, marching
>>> cubes watershed and region growing, then it works completely well. The
>>> problem arises only when cut for watershed and region growing algorithm.
>>>>
>>> What am I doing wrong?
>>>
>>> To understand my problem better, please see my screenshots on the following
>>> link.
>>>
>>>
>>>
>>> http://www.wopsys.com/bilder/segmentation.html
>>>>
>>>
>>>
>>>
>>> To determine whether there missing of any geometrical informations. I had
>>> sent the following outputs of tests.
>>>
>>> http://www.wopsys.com/Outputs/Output_MarchingCubes.txt
>>>>
>>> http://www.wopsys.com/Outputs/Output_VolumeRendering.txt
>>> http://www.wopsys.com/Outputs/Output_Watershed.txt
>>>>
>>> http://www.wopsys.com/Outputs/Output_RegionGrowing.txt
>>>
>>> Thanks.
>>>
>>>
>>> ________________________________
>>>>
>>> Von: Luis Ibanez <luis.ibanez at kitware.com>
>>> An: Yusuf OEZBEK <nasil122002 at yahoo.de>
>>>>
>>> CC: ITK Mailinglist <insight-users at itk.org>; VTK Mailinglist
>>> <vtkusers at vtk.org>; nasil122002 at gmail.com
>>>>
>>> Gesendet: Sonntag, den 18. April 2010, 1:12:33 Uhr
>>> Betreff: Re: [Insight-users] Cropping Problem
>>>
>>>
>>> Hi Yusuf,
>>>
>>>
>>> You should start by separating the segmentation
>>> problem from the visualization problem.
>>>>
>>>
>>>
>>> Please do the following:
>>>
>>> 0) Just after you call:
>>>
>>>   
>> reader->SetFileNames( fileNames );
>>>    reader->Update();
>>>
>>>    add
>>>
>>>    reader->GetOutput()->Print( std::cout );
>>>
>>>    then
>>>
>>> 1) Run the ITK segmentation pipeline until you
>>>>
>>>     get the segmented image, and save it as a
>>>     MetaImage file (with extension .mhd)
>>>
>>>
>>> 2) Post the content of the resulting .mhd file
>>>     back to the list, as well as the print out of
>>>>
>>>     the statement:
>>>
>>>    reader->GetOutput()->Print( std::cout );
>>>
>>>
>>> 3) Use Paraview (www.paraview.org) to load the
>>>>
>>>     resulting image and extracting an iso-surface.
>>>     Compare that iso-surface with the one that
>>>     you get by directly from the DICOM image.
>>>     (and let us know what you
>> find).
>>>
>>>
>>> With the information from (2) we should be
>>> able to identify if any geometrical information
>>> is missing from the ITK processing pipeline.
>>>
>>>
>>>    Thanks
>>>>
>>>
>>>
>>>          Luis
>>>
>>>
>>>
>>>
>>>
>>> _____________________________________
>>> Powered by www.kitware.com
>>>>
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>>>> Kitware offers ITK Training Courses, for more information visit:
>>>>> http://www.kitware.com/products/protraining.html
>>>
>>> Please keep messages on-topic and check the ITK FAQ at:
>>>>> http://www.itk.org/Wiki/ITK_FAQ
>>>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.itk.org/mailman/listinfo/insight-users
>>>
>>>>>
>>
>>
>
>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100528/32a81c90/attachment.htm>


More information about the vtkusers mailing list