<div dir="ltr">If I change that, I get the following error:<br>error C2440: 'type cast' : cannot convert from 'void *' to 'itk::SmartPointer<TObjectType>'<br>1> with<br>1> [<br>
1> TObjectType=itk::Image<PixelType,2><br>1> ]<br>1> No constructor could take the source type, or constructor overload resolution was ambiguous<br><br>Using the function is not justified per se, but I am also no able to figure out where I am going wrong.<br>
<br>- Prathamesh<br><br><div class="gmail_quote">On Fri, Oct 22, 2010 at 11:52 AM, David Doria <span dir="ltr"><<a href="mailto:daviddoria@gmail.com">daviddoria@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div><div class="gmail_quote"><div><div></div><div class="h5">On Fri, Oct 22, 2010 at 12:44 PM, Prathamesh Kulkarni <span dir="ltr"><<a href="mailto:prathameshmkulkarni@gmail.com" target="_blank">prathameshmkulkarni@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<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?</div></blockquote><div><br></div></div></div><div>The ::Pointer member is already a pointer, so there should be no need for the '*'. That is, change</div>
<div class="im"><div class="gmail_quote">
<br></div> ImageType::Pointer *itk_img_ptr = (ImageType::Pointer*)itk_img_void_ptr;</div></div><div class="gmail_quote"><br></div><div class="gmail_quote">to</div><div class="im"><div class="gmail_quote"><br></div><div class="gmail_quote">
ImageType::Pointer itk_img_ptr = (ImageType::Pointer)itk_img_void_ptr;<br clear="all">
<br></div></div><div class="gmail_quote">Here is a demo of ImageToVTKImageFilter<br><div><a href="http://www.itk.org/Wiki/ITK/Examples/ItkVtkGlue/ImageToVTKImageFilter" target="_blank">http://www.itk.org/Wiki/ITK/Examples/ItkVtkGlue/ImageToVTKImageFilter</a></div>
<div><br></div><div>I'm not sure I follow why you need your own function, isn't this conversion exactly what this filter does?</div><div><a href="http://www.itk.org/Wiki/ITK/Examples/ItkVtkGlue/ImageToVTKImageFilter" target="_blank"></a><div>
<br></div></div><font color="#888888"><div>David</div></font></div></div></div>
</blockquote></div><br></div>