[ITK] [ITK-users] itkImageToVtkImageFilter does not work

Matt McCormick matt.mccormick at kitware.com
Wed Dec 6 09:50:17 EST 2017


Hi,

This line :

      typedef itk::ImageToVTKImageFilter<OutputImageType>   ConnectorType;

should be

      typedef itk::ImageToVTKImageFilter<RGBImageType>   ConnectorType;


Another useful example:

  https://itk.org/ITKExamples/src/Bridge/VtkGlue/ConvertAnRGBitkImageTovtkImageData/Documentation.html


Also, please check out the new Discourse forum where a lot of
discussion is taking place:

  https://discourse.itk.org/


Thanks,
Matt

On Wed, Dec 6, 2017 at 1:02 AM, arwtyxouymz
<arw.tyx-ouy_mz at suou.waseda.jp> wrote:
> Hi,
>
> I am a newer of itk but i have some experience of vtk.
>
> I want to convert my itk image to vtk image by using
> itkImageToVtkImageFilter.
> In detail, I refer to  this labeling example
> <https://itk.org/Wiki/ITK/Examples/ImageProcessing/ConnectedComponentImageFilter>
> , and I want to use not QuickView but vtk Rendering System.
>
> I succeeded itkImage, but failed in itkLabelToRGBImageFilter.
>
> My code snippet is below:
>
>     const unsigned int Dimension = 2;
>     typedef unsigned char                       PixelType;
>     typedef itk::RGBPixel<unsigned char>         RGBPixelType;
>     typedef itk::Image<PixelType, Dimension>     ImageType;
>     typedef itk::Image<RGBPixelType, Dimension>  RGBImageType;
>     typedef itk::Image< unsigned short, Dimension > OutputImageType;
>
>     typedef itk::ConnectedComponentImageFilter <ImageType, OutputImageType >
>             ConnectedComponentImageFilterType;
>     ConnectedComponentImageFilterType::Pointer connected =
>             ConnectedComponentImageFilterType::New ();
>     connected->SetInput(image);
>     connected->Update();
>
>     typedef itk::LabelToRGBImageFilter<OutputImageType, RGBImageType>
> RGBFilterType;
>     RGBFilterType::Pointer rgbFilter = RGBFilterType::New();
>     rgbFilter->SetInput( connected->GetOutput() );
>
>     typedef itk::ImageToVTKImageFilter<OutputImageType>   ConnectorType;
>     ConnectorType::Pointer connector = ConnectorType::New();
>     connected->SetInput(rgbFilter->GetOutput());
>     connector->Update();
>
> I thought rgbFilter->GetOutput() is itkImage Object, but it's wrong.
>
> How should i do?
> Please help me!
>
>
>
> --
> Sent from: http://itk-users.7.n7.nabble.com/
> The ITK community is transitioning from this mailing list to discourse.itk.org. Please join us there!
> ________________________________
> 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.php
>
> 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://public.kitware.com/mailman/listinfo/insight-users
The ITK community is transitioning from this mailing list to discourse.itk.org. Please join us there!
________________________________
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.php

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://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list