[Insight-users] Convert vtkImageData to itk Image
John Drescher
drescherjm at gmail.com
Wed Sep 7 12:33:35 EDT 2011
On Wed, Sep 7, 2011 at 12:27 PM, Jothy <jothybasu at gmail.com> wrote:
> Hi all,
>
> I am trying to convert a vtkImageData into a itk image. I tried the
> following as given in the itk examples wiki.
>
> typedef itk::Image<float, 2> ImageType;
>
> typedef itk::VTKImageToImageFilter<ImageType> VTKImageToImageType;
>
> VTKImageToImageType::Pointer vtkImageToImageFilter =
> VTKImageToImageType::New();
>
> vtkImageToImageFilter->SetInput(inputVTKImage);
>
> vtkImageToImageFilter->Update();
>
> But the program crashes. I found in the users list that
> VTKImageToImageFilter is not supposed to be used directly. I am new to itk
> and it seems to be highly templated.
>
> I am a novice new c++ user to decipher the itk templates fully. Is there any
> easy to follow example on this?
>
I use this template exactly like you do (except for 3d unsigned short images):
typedef quint16 MaskPixelType;
typedef itk::Image< MaskPixelType, 3 > MaskImageType;
m_pVTKToITK = itk::VTKImageToImageFilter<MaskImageType>::New();
m_pVTKToITK->SetInput(pMask->GetOutput());
m_pVTKToITK->Update();
John
More information about the Insight-users
mailing list