<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Hi Gordian,</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">can you try giving the filename .nrrd or .mha extension instead of .dcm?</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Regards,</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Dženan</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Nov 25, 2016 at 10:20 AM, Kabelitz, Gordian <span dir="ltr"><<a href="mailto:Gordian.Kabelitz@medma.uni-heidelberg.de" target="_blank">Gordian.Kabelitz@medma.uni-heidelberg.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
i started working on a program that uses ITK in combination with OpenCV.<br>
At the moment I encounter the problem with the image conversion from cv::Mat to itk::image.<br>
Using OpenCVImageBridge:: ITKImageToCVMat() can convert ITK images to cv::Mat and works pretty well. That part is similar to [1].<br>
<br>
A problem occurs, when I want to convert the images back to ITK images by using OpenCVImageBridge:: CVMatToITKImage ().<br>
Here is a code snippet (similar to [2]):<br>
[...]<br>
cv::Mat outimage = cvImage; // outimage is an image previously converted from itk::image to cv::Mat<br>
typedef itk::OpenCVImageBridge BridgeType;<br>
CVImageType::Pointer outputImage = BridgeType::CVMatToITKImage<<wbr>CVImageType>(outimage);<br>
<br>
typedef itk::CastImageFilter< CVImageType, OutImage > CastFilterType;<br>
CastFilterType::Pointer caster = CastFilterType::New();<br>
 caster->SetInput(outputImage);<br>
<br>
typedef itk::ImageFileWriter<OutImage> WriterType;<br>
WriterType::Pointer outputWriter = WriterType::New();<br>
outputWriter->SetImageIO(<wbr>gdcmIO);<br>
outputWriter->SetInput(caster-<wbr>>GetOutput());<br>
outputWriter->SetFileName(<wbr>argv[2]);<br>
try  {<br>
          outputWriter->Update();<br>
  }   catch (itk::ExceptionObject err)  {<br>
          std::cout << "EXCEPTION CAUGHT!" << std::endl;<br>
          std::cout << err << std::endl;<br>
          return EXIT_FAILURE;<br>
  }<br>
<br>
It compiles and runs with only the following error:<br>
Description: itk::ERROR: GDCMImageIO(0000000003B22290): A Floating point buffer was passed but the stored pixel type was not specified. This is currently not supported.<br>
<br>
Is there an option to get a writable image? Did I make an obvious mistake?<br>
Is there a website to get more examples working for ITK with Opencv?<br>
<br>
Thanks in advance,<br>
Gordian<br>
<br>
[1]: <a href="https://github.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial" rel="noreferrer" target="_blank">https://github.com/<wbr>InsightSoftwareConsortium/ITK-<wbr>OpenCV-Bridge-Tutorial</a><br>
[2]: <a href="https://github.com/InsightSoftwareConsortium/ITK-OpenCV-Bridge-Tutorial/blob/master/Exercises/ITKOpenCVBridge/exercise2/BasicVideoFilteringITKOpenCVBridge.cxx" rel="noreferrer" target="_blank">https://github.com/<wbr>InsightSoftwareConsortium/ITK-<wbr>OpenCV-Bridge-Tutorial/blob/<wbr>master/Exercises/<wbr>ITKOpenCVBridge/exercise2/<wbr>BasicVideoFilteringITKOpenCVBr<wbr>idge.cxx</a><br>
<br>
<br>
______________________________<wbr>_______<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" 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" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" rel="noreferrer" target="_blank">http://www.itk.org/Wiki/ITK_<wbr>FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/insight-users</a><br>
</blockquote></div><br></div>