<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hello VTK team,<div class=""><br class=""></div><div class="">I try to solve a next problem. I try to visualize a medical mesh by <span class="" style="background-color: rgb(228, 228, 255); font-family: Menlo; font-size: 9pt;">vtkDiscreteMarchingCubes</span> from DICOM files but I combine your the best of best visualization toolkit and OpenCV for preprocessing. Here is my approach:</div><div class=""><br class=""></div><div class="">1. I read medical DICOM files by VTK</div><div class="">2. I convert vtkImageData to cv::Mat</div><div class="">3. .... doing something interest ...</div><div class="">4. I convert cv::Mat to vtkImageData (source code is below)</div><div class=""><br class=""></div><div class=""><pre class="" style="background-color: rgb(255, 255, 255); font-family: Menlo; font-size: 9pt;"><span class="" style="color: rgb(0, 0, 128); font-weight: bold;">bool </span>PnLabImportOpenCVMat2VtkImageData(<span class="" style="color: rgb(0, 128, 128);">cv</span>::<span class="" style="color: rgb(0, 128, 128);">Mat </span>&src, <span class="" style="color: rgb(0, 128, 128);">vtkSmartPointer</span><<span class="" style="color: rgb(0, 128, 128);">vtkImageData</span>> dest) {<br class="">    <span class="" style="color: rgb(31, 84, 46); font-weight: bold;">assert</span>(src.<span class="" style="color: rgb(102, 14, 122);">data </span>!= <span class="" style="color: rgb(31, 84, 46); font-weight: bold;">NULL</span>);<br class=""><br class="">    <span class="" style="color: rgb(0, 128, 128);">vtkSmartPointer</span><<span class="" style="color: rgb(0, 128, 128);">vtkImageImport</span>> importer;<br class="">    importer <span class="" style="color: rgb(0, 128, 128);">= vtkSmartPointer</span><<span class="" style="color: rgb(0, 128, 128);">vtkImageImport</span>>::New();<br class=""><br class="">    <span class="" style="color: rgb(0, 0, 128); font-weight: bold;">if </span>(dest) {<br class="">        importer<span class="" style="color: rgb(0, 128, 128);">-></span>SetOutput(dest);<br class="">    }<br class=""><br class="">    importer<span class="" style="color: rgb(0, 128, 128);">-></span>SetDataSpacing(<span class="" style="color: rgb(0, 0, 255);">1</span>, <span class="" style="color: rgb(0, 0, 255);">1</span>, <span class="" style="color: rgb(0, 0, 255);">1</span>);<br class="">    importer<span class="" style="color: rgb(0, 128, 128);">-></span>SetDataOrigin(<span class="" style="color: rgb(0, 0, 255);">0</span>, <span class="" style="color: rgb(0, 0, 255);">0</span>, <span class="" style="color: rgb(0, 0, 255);">0</span>);<br class="">    importer<span class="" style="color: rgb(0, 128, 128);">-></span>SetWholeExtent(<span class="" style="color: rgb(0, 0, 255);">0</span>, src.<span class="" style="color: rgb(102, 14, 122);">cols </span>- <span class="" style="color: rgb(0, 0, 255);">1</span>, <span class="" style="color: rgb(0, 0, 255);">0</span>, src.<span class="" style="color: rgb(102, 14, 122);">rows </span>- <span class="" style="color: rgb(0, 0, 255);">1</span>, <span class="" style="color: rgb(0, 0, 255);">0</span>, <span class="" style="color: rgb(0, 0, 255);">0</span>);<br class="">    importer<span class="" style="color: rgb(0, 128, 128);">-></span>SetDataScalarTypeToDouble();<br class="">    importer<span class="" style="color: rgb(0, 128, 128);">-></span>SetNumberOfScalarComponents(<span class="" style="color: rgb(0, 0, 255);">1</span>);<br class="">    importer<span class="" style="color: rgb(0, 128, 128);">-></span>SetImportVoidPointer(src.<span class="" style="color: rgb(102, 14, 122);">data</span>);<br class="">    importer<span class="" style="color: rgb(0, 128, 128);">-></span>Update();<br class=""><br class="">    <span class="" style="color: rgb(0, 0, 128); font-weight: bold;">return </span>(<span class="" style="color: rgb(0, 0, 128); font-weight: bold;">true</span>);<br class="">} <span class="" style="color: rgb(128, 128, 128); font-style: italic;">//[end-function] ImportOpenCVMat2VtkImageData</span></pre><div class="">5. I add vtkImageData to vtkImageCacheFilter</div></div><div class=""><br class=""></div><div class=""><pre class="" style="background-color: rgb(255, 255, 255); font-family: Menlo; font-size: 9pt;"><span class="" style="background-color: rgb(228, 228, 255);">vtkSmartPointer</span><<span class="" style="color: rgb(0, 128, 128);">vtkDiscreteMarchingCubes</span>> discrete_cubes;<br class=""><span class="" style="background-color: rgb(228, 228, 255);">vtkSmartPointer</span><<span class="" style="color: rgb(0, 128, 128);">vtkImageData</span>> vtk_img_data;<br class=""><span class="" style="background-color: rgb(228, 228, 255);">vtkSmartPointer</span><<span class="" style="color: rgb(0, 128, 128);">vtkImageCacheFilter</span>> vtk_multiple_data;<br class=""><br class="">vtk_multiple_data <span class="" style="color: rgb(0, 128, 128);">= </span><span class="" style="background-color: rgb(228, 228, 255);">vtkSmartPointer</span><<span class="" style="color: rgb(0, 128, 128);">vtkImageCacheFilter</span>>::New();<br class="">discrete_cubes    <span class="" style="color: rgb(0, 128, 128);">= </span><span class="" style="background-color: rgb(228, 228, 255);">vtkSmartPointer</span><<span class="" style="color: rgb(0, 128, 128);">vtkDiscreteMarchingCubes</span>>::New();<br class=""><br class=""><span class="" style="color: rgb(0, 0, 128); font-weight: bold;">for</span>(<span class="" style="color: rgb(0, 0, 128); font-weight: bold;">int </span>i=<span class="" style="color: rgb(0, 0, 255);">0</span>; i < slices.size(); i++) {<br class="">    vtk_img_data <span class="" style="color: rgb(0, 128, 128);">= </span><span class="" style="background-color: rgb(228, 228, 255);">vtkSmartPointer</span><<span class="" style="color: rgb(0, 128, 128);">vtkImageData</span>>::New();<br class="">    PnLabImportOpenCVMat2VtkImageData(*slices<span class="" style="color: rgb(0, 128, 128);">[</span>i<span class="" style="color: rgb(0, 128, 128);">]</span>, vtk_img_data);<br class="">    vtk_multiple_data<span class="" style="color: rgb(0, 128, 128);">-></span>AddInputData(vtk_img_data);<br class="">}<br class="">vtk_multiple_data<span class="" style="color: rgb(0, 128, 128);">-></span>Update();</pre><pre class="" style="background-color: rgb(255, 255, 255);"><pre class="" style="font-family: Menlo; font-size: 9pt;"><span class="" style="background-color: rgb(228, 228, 255);">discrete_cubes</span><span class="" style="color: rgb(0, 128, 128);">-></span>SetInputData(vtk_multiple_data<span class="" style="color: rgb(0, 128, 128);">-></span>GetOutput());<br class=""><span class="" style="background-color: rgb(228, 228, 255);">discrete_cubes</span><span class="" style="color: rgb(0, 128, 128);">-></span>GenerateValues(<span class="" style="color: rgb(0, 0, 255);">1</span>, <span class="" style="color: rgb(0, 0, 255);">1</span>, <span class="" style="color: rgb(0, 0, 255);">1</span>);<br class=""><span class="" style="background-color: rgb(228, 228, 255);">discrete_cubes</span><span class="" style="color: rgb(0, 128, 128);">-></span>Update();</pre><div class="" style="font-family: Menlo; font-size: 9pt;"><span class="" style="font-size: 9pt;">But after </span><span class="" style="font-size: 9pt;">vtk_multiple_data</span><span class="" style="font-size: 9pt; color: rgb(0, 128, 128);">-></span><span class="" style="font-size: 9pt;">Update(); I got error message </span></div><div class="" style="font-family: Menlo; font-size: 9pt;"><span class="" style="font-size: 9pt;"><br class=""></span></div><div class=""><font face="Menlo" class="">ERROR: In /Users/mari/ProgramsToBuild/VTK-6.3.0/Common/ExecutionModel/vtkDemandDrivenPipeline.cxx, line 720
vtkCachedStreamingDemandDrivenPipeline (0x7f89d8c02b60): Input port 0 of algorithm vtkImageCacheFilter(0x7f89d8c02400) has 20 connections but is not repeatable.</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">I don't know what I'm doing wrong. Please can you help me?</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">Thank you</font></div><div class=""><font face="Menlo" class="">Mari</font></div></pre></div><div class=""><br class=""></div></body></html>