[Insight-users] converting vtkImageData to itkImage using itk::VTKImageToImageFilter

Prathamesh Kulkarni prathameshmkulkarni at gmail.com
Fri Jul 30 13:46:21 EDT 2010


Hello ITK users,

I am have started to use ITK a few days ago!

I am having trouble with converting vtkImageData to itkImage. The previous
posts on the list did not help me. Following is my code for converting
vtkImage to itkImage:

>
>     typedef itk::Image<unsigned char, 2> ImageType;
>
>     typedef itk::VTKImageToImageFilter<ImageType> VTKToITKConnector;
>     VTKToITKConnector::Pointer VTK_to_ITK_filter =
> VTKToITKConnector::New();
>
>
>     VTK_to_ITK_filter->SetInput(vtkImageData); //vtkImageData is unsigned
> char and single channel
>     VTK_to_ITK_filter->Update();
>
>     ImageType::Pointer itk_image = VTK_to_ITK_filter->GetOutput(); //THIS
> LINE  GIVES THE ERROR SHOWN BELOW
>
>
>     //itk::SmartPointer<ImageType> itk_image =
> VTK_to_ITK_filter->GetOutput();
>
>
> Could you please point me out to what I am doing wrong? I could so a
> speckle noise simulation from an image read from the disk, but I am not able
> to do the same on a vtkImageData.
>
> Any help will be highly appreciated.
>
> Thanks,
> Prathamesh
>

ERROR:
error C2679: binary '=' : no operator found which takes a right-hand operand
of type 'const itk::Image<TPixel,
VImageDimension> *' (or there is no acceptable conversion)
1>        with
1>        [
1>            TPixel=unsigned char,
1>            VImageDimension=2
1>        ]
1>
c:\itk\insighttoolkit-3.18.0\insighttoolkit-3.18.0\code\common\itkSmartPointer.h(112):
could be 'itk::SmartPointer<TObjectType>
&itk::SmartPointer<TObjectType>::operator =(const
itk::SmartPointer<TObjectType> &)'
1>        with
1>        [
1>            TObjectType=itk::Image<unsigned char,2>
1>        ]
1>
c:\itk\insighttoolkit-3.18.0\insighttoolkit-3.18.0\code\common\itkSmartPointer.h(116):
or       'itk::SmartPointer<TObjectType>
&itk::SmartPointer<TObjectType>::operator
=(itk::Image<TPixel,VImageDimension> *)'
1>        with
1>        [
1>            TObjectType=itk::Image<unsigned char,2>,
1>            TPixel=unsigned char,
1>            VImageDimension=2
1>        ]
1>        while trying to match the argument list
'(itk::SmartPointer<TObjectType>, const itk::Image<TPixel,VImageDimension>
*)'
1>        with
1>        [
1>            TObjectType=itk::Image<unsigned char,2>
1>        ]
1>        and
1>        [
1>            TPixel=unsigned char,
1>            VImageDimension=2
1>        ]


>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100730/b7aa06c5/attachment.htm>


More information about the Insight-users mailing list