Hi Felix,<br><br>I am using ITK 3.20.0 and itk::VTKImageToImageFilter was from the latest Slicer 4.0 source code. <br><br>I was just able to convert a VTK image to ITK with this template function without using the itk::VTKImageToImageFilter .<br>
<br>IMAGEDATATYPE = short and DIMENSIONS = 3<br><br>typename itk::Image<IMAGEDATATYPE, DIMENSIONS>::Pointer convertVtkToItk(vtkImageData* vtkInput)<br> {<br> typedef itk::Image<IMAGEDATATYPE, DIMENSIONS> InputImageType;<br>
typedef itk::VTKImageImport<InputImageType> InputImageImportType;<br> vtkSmartPointer<vtkImageExport> inputImageExporter = vtkImageExport::New();<br> inputImageExporter->SetInput(vtkInput);<br>
typename InputImageImportType::Pointer inputImageImporter = InputImageImportType::New();<br> ConnectPipelines(inputImageExporter.GetPointer(), inputImageImporter);<br> typename InputImageType::Pointer outputImage = const_cast<InputImageType*>(inputImageImporter->GetOutput());<br>
outputImage->Update();<br> if(outputImage.IsNull())<br> {<br> QLOG_WARN() << "ITK image is invalid.";<br> }<br> return outputImage;<br> }<br><br>Cheers,<br>
<br><br><br><div class="gmail_quote">On Wed, Feb 1, 2012 at 2:34 PM, Félix C. Morency <span dir="ltr"><<a href="mailto:felix.morency@gmail.com">felix.morency@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">
Karl,<br>
<br>
Try double instead of float in your image type.<br>
<br>
Also, could you tell me what version of ITK you are using?<br>
<br>
Thanks,<br>
-Félix<br>
<div><div class="h5"><br>
On Wed, Feb 1, 2012 at 1:53 PM, Karl Diedrich<br>
<<a href="mailto:karl.diedrich@azeresearch.com">karl.diedrich@azeresearch.com</a>> wrote:<br>
> Hello,<br>
><br>
> I am trying to use itk::VTKImageToImageFilter to to convert a VTK image to<br>
> an ITK image.<br>
> The call vtkImageToImageFilter->Update(); never returns but there is no<br>
> error message and program simply stops.<br>
><br>
> vtkImageData* vtkInput;<br>
><br>
><br>
> typedef itk::Image<float, 3> ImageType;<br>
><br>
> typedef itk::VTKImageToImageFilter<ImageType> VTKImageToImageType;<br>
><br>
> typename VTKImageToImageType::Pointer vtkImageToImageFilter =<br>
> VTKImageToImageType::New();<br>
> QLOG_DEBUG() << "Prepared Filter";<br>
> vtkImageToImageFilter->SetInput(vtkInput);<br>
> QLOG_DEBUG() << "Set input to filter";<br>
> vtkImageToImageFilter->Update();<br>
> QLOG_DEBUG() << "Updated filter";<br>
> typename ImageType::ConstPointer itkOutput =<br>
> vtkImageToImageFilter->GetOutput();<br>
> QLOG_DEBUG() << "Got output";<br>
><br>
><br>
><br>
><br>
> --<br>
> Karl Diedrich, Ph.D.<br>
> Principal Engineer<br>
> ----------------------------------------<br>
> AZE Research and Development<br>
> 1 Broadway, 14th floor<br>
> Cambridge, MA 02142<br>
> Tel: <a href="tel:%2B1%20%28617%29%20475-1502" value="+16174751502">+1 (617) 475-1502</a><br>
> Cell: <a href="tel:%2B1%20%28801%29%20350-1251" value="+18013501251">+1 (801) 350-1251</a><br>
> <a href="http://www.azeofamerica.com" target="_blank">www.azeofamerica.com</a><br>
><br>
</div></div>> _____________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Kitware offers ITK Training Courses, for more information visit:<br>
> <a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
><br>
> Please keep messages on-topic and check the ITK FAQ at:<br>
> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
><br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
--<br>
--<br>
Félix C. Morency, M.Sc.<br>
Plateforme d’analyse et de visualisation d’images<br>
Centre Hospitalier Universitaire de Sherbrooke<br>
Centre de recherche clinique Étienne-Le Bel<br>
Local Z5-3031 | <a href="tel:819.346.1110%20ext%2016634" value="+18193461110">819.346.1110 ext 16634</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><font color="#888888">Karl Diedrich, Ph.D.<br>Principal Engineer<br>----------------------------------------<br>
AZE Research and Development<br>1 Broadway, 14th floor<br>Cambridge, MA 02142<br>Tel: <a value="+16174751502">+1 (617) 475-1502</a><br>Cell: <a value="+19492288509">+1 (801) 350-1251</a><br><a href="http://www.azeofamerica.com/" target="_blank">www.azeofamerica.com</a></font><br>