[Insight-users] cannot return output of itk::ImageToVTKImageFilter
Prathamesh Kulkarni
prathameshmkulkarni at gmail.com
Fri Oct 22 12:44:05 EDT 2010
Hello all,
I am converting an ITK image to VTK image and rendering it. However, I am
not able to return the filter's output from the function which does the
conversion. Following is a code snippet.
vtkSmartPointer<vtkImageData> convertITKImageToVTKImage(void
*itk_img_void_ptr){
typedef float PixelType;
const unsigned int dimensions = 2;
typedef itk::Image<PixelType, dimensions> ImageType;
ImageType::Pointer itk_img = ImageType::New();
ImageType::Pointer *itk_img_ptr = (ImageType::Pointer*)itk_img_void_ptr;
itk_img = itk_img_ptr->GetPointer();
typedef itk::ImageToVTKImageFilter<ImageType> ITKToVTKFilterType;
ITKToVTKFilterType::Pointer ITK_to_VTK_filter =
ITKToVTKFilterType::New();
ITK_to_VTK_filter->SetInput(itk_img);
ITK_to_VTK_filter->Update();
vtkSmartPointer<vtkImageData> vtk_image =
ITK_to_VTK_filter->GetOutput();
//vtk_image->Update();
//uncomment to test.. THIS RENDERING WORKS
renderImage(castImage(vtk_image, std::string("unsigned char")), true);
return vtk_image;
}
void foo(){
vtkSmartPointer<vtkImageData> BScan_vtk_image =
convertITKImageToVTKImage(itk_image_void_ptr);
//THIS RENDERING FAILS - ERROR: unhandled exception at
itkVTKImageExportBase.cxx
renderImage(OCTCommon::castImage(BScan_vtk_image, std::string("unsigned
char")), true);
}
Please point me out, where am I going wrong?
Thanks,
Prathamesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20101022/c50f6c73/attachment.htm>
More information about the Insight-users
mailing list