[ITK-users] itkImageToVtkImageFilter does not work

arwtyxouymz arw.tyx-ouy_mz at suou.waseda.jp
Wed Dec 6 01:02:50 EST 2017


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/


More information about the Insight-users mailing list