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

Karthik Krishnan karthik.krishnan at kitware.com
Fri Jul 30 13:58:29 EDT 2010


Prathamesh:

As the error indicates, the itk::VTKImageToImageFilter's GetOutput() method
returns a const image. So try :

  ImageType::ConstPointer itk_image = VTK_to_ITK_filter->GetOutput();

instead.


--
karthik

On Fri, Jul 30, 2010 at 11:16 PM, Prathamesh Kulkarni <
prathameshmkulkarni at gmail.com> wrote:

>
> 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>        ]
>
>
>>
>>
>
>
>
> _____________________________________
> 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.itk.org/pipermail/insight-users/attachments/20100730/af133436/attachment.htm>


More information about the Insight-users mailing list