<div dir="ltr"><br>Hello all,<br><br>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.<br>
<br>vtkSmartPointer<vtkImageData> convertITKImageToVTKImage(void *itk_img_void_ptr){<br> typedef float PixelType;<br> const unsigned int dimensions = 2;<br> typedef itk::Image<PixelType, dimensions> ImageType;<br>
<br> ImageType::Pointer itk_img = ImageType::New();<br> ImageType::Pointer *itk_img_ptr = (ImageType::Pointer*)itk_img_void_ptr;<br> itk_img = itk_img_ptr->GetPointer();<br><br> typedef itk::ImageToVTKImageFilter<ImageType> ITKToVTKFilterType;<br>
ITKToVTKFilterType::Pointer ITK_to_VTK_filter = ITKToVTKFilterType::New();<br><br> ITK_to_VTK_filter->SetInput(itk_img);<br> ITK_to_VTK_filter->Update();<br><br> vtkSmartPointer<vtkImageData> vtk_image = ITK_to_VTK_filter->GetOutput();<br>
//vtk_image->Update();<br> <br> //uncomment to test.. THIS RENDERING WORKS<br> renderImage(castImage(vtk_image, std::string("unsigned char")), true);<br><br> return vtk_image;<br>}<br><br>void foo(){<br>
vtkSmartPointer<vtkImageData> BScan_vtk_image = convertITKImageToVTKImage(itk_image_void_ptr);<br> <br> //THIS RENDERING FAILS - ERROR: unhandled exception at itkVTKImageExportBase.cxx <br> renderImage(OCTCommon::castImage(BScan_vtk_image, std::string("unsigned char")), true); <br>
}<br><br><br>Please point me out, where am I going wrong?<br><br>Thanks,<br>Prathamesh<br></div>