I tried out the itk vtk import/export connections to load a 3d image in itk and then 3d render it in vtk but the same problem reappeared. Below is my adjusted code and the specific error I get:<div><br></div><div>Code:</div>
<div><br></div><div><div>const unsigned int<span class="Apple-tab-span" style="white-space:pre">        </span>InputDimension3D = 3;</div><div>typedef unsigned short OutputPixelType;</div></div><div><br></div><div><div>typedef itk::Image&lt;OutputPixelType, InputDimension3D&gt;<span class="Apple-tab-span" style="white-space:pre">        </span>InputImageType3D;</div>
<div>typedef itk::ImageSeriesReader&lt;InputImageType3D&gt;<span class="Apple-tab-span" style="white-space:pre">        </span>ReaderType3D;</div></div><div><br></div><div><div>typedef itk::VTKImageExport&lt; InputImageType3D &gt; ExportFilterType;</div>
<div>typedef itk::VTKImageImport&lt; InputImageType3D &gt; ImportFilterType;</div></div><div><br></div><div><br></div><div><div><span class="Apple-tab-span" style="white-space:pre">        </span>//Load the data</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>ReaderType3D::Pointer reader = ReaderType3D::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>//we need to make use of GDCMImageIO to assist with reading a series of DICOM files in a different directory</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>ImageIOType::Pointer dicomReadIO = ImageIOType::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>reader-&gt;SetImageIO( dicomReadIO );</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>//get the directory whilst instructing to make use of as much information to distinguish between DICOM files</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>nameGenerator-&gt;SetUseSeriesDetails( true );</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>nameGenerator-&gt;SetInputDirectory( outputDirectory );</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>//extraxt the filenames</div>
<div>    SeriesIdContainer seriesUID = nameGenerator-&gt;GetSeriesUIDs();</div><div>    FileNamesContainer fileNames = nameGenerator-&gt;GetFileNames( seriesUID.begin()-&gt;c_str() );</div><div><br></div><div>    reader-&gt;SetFileNames( fileNames );</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div>    try</div><div>      {</div><div>      reader-&gt;Update();</div><div>      }</div><div>    catch (itk::ExceptionObject &amp;ex)</div><div>      {</div>
<div>      std::cout &lt;&lt; ex &lt;&lt; std::endl;</div><div>      }</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>ExportFilterType::Pointer itkExporter = ExportFilterType::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>itkExporter-&gt;SetInput( reader-&gt;GetOutput() );</div><div>    //Create the vtkImageImport and connect it to the itk::VTKImageExport instance.</div><div>
    vtkImageImport* vtkImporter = vtkImageImport::New();  </div><div>    ConnectPipelines(itkExporter, vtkImporter);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>//Smoothing the edges with gaussian</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer&lt;vtkImageGaussianSmooth&gt; gaussianSmoothFilter = vtkSmartPointer&lt;vtkImageGaussianSmooth&gt;::New(); </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>gaussianSmoothFilter-&gt;SetInput(vtkImporter-&gt;GetOutput());</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>//gaussianSmoothFilter-&gt;SetInputConnection(vtkImporter-&gt;GetOutputPort()); </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>gaussianSmoothFilter-&gt;SetRadiusFactor(2); </div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>//Marching Cubes</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer&lt;vtkMarchingCubes&gt; surface = vtkSmartPointer&lt;vtkMarchingCubes&gt;::New(); </div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>surface-&gt;SetInput(gaussianSmoothFilter-&gt;GetOutput());</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>//surface-&gt;SetInputConnection(gaussianSmoothFilter-&gt;GetOutputPort());</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>surface-&gt;ComputeNormalsOn();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>surface-&gt;ComputeGradientsOn();</div><div><br></div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>//Create a mapper</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer&lt;vtkPolyDataMapper&gt; mapper = vtkSmartPointer&lt;vtkPolyDataMapper&gt;::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>mapper-&gt;SetInput(surface-&gt;GetOutput());</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>mapper-&gt;SetInputConnection(surface-&gt;GetOutputPort());</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>// Visualize</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer&lt;vtkActor&gt; actor = vtkSmartPointer&lt;vtkActor&gt;::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>actor-&gt;SetMapper(mapper);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer&lt;vtkRenderer&gt; renderer = vtkSmartPointer&lt;vtkRenderer&gt;::New(); </div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer&lt;vtkRenderWindow&gt; renderWindow = vtkSmartPointer&lt;vtkRenderWindow&gt;::New();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer&lt;vtkRenderWindowInteractor&gt; interactor = vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;::New(); </div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>renderer-&gt;AddActor(actor); </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>renderWindow-&gt;AddRenderer(renderer); </div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>interactor-&gt;SetRenderWindow(renderWindow); </div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>renderWindow-&gt;SetSize(800,600); </div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>renderWindow-&gt;Render(); </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>interactor-&gt;Start(); </div><div><br></div><div><br></div>
<div><br></div><div>Error:</div><div><br></div><div><div>ERROR: In C:.....\vtkMarchingCubes.cxx, line 415</div><div>vtkMarchingCubes (0000000002F58D40): Cannot contour data of dimension != 3</div></div><div><br></div><div>
<br></div><div>Thanks for any help</div><div><br></div><div><br></div><div><br></div><br><div class="gmail_quote">On Sun, Aug 28, 2011 at 1:24 AM, Richard Beare <span dir="ltr">&lt;<a href="mailto:richard.beare@gmail.com">richard.beare@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">You can use ITK to load the segmented series as a 3D image and either<br>
save it to a 3d format and load in vtk, or use the itk to vtk<br>
connector so to transfer the 3d image object to the vtk part of your<br>
code. There are examples of this in the InsightApplications suite.<br>
<br>
It is also likely, although I haven&#39;t checked, that vtk has a dicom<br>
series reader, enabling it to read all of the dicoms into a 3d object<br>
<div><div></div><div class="h5"><br>
On Sun, Aug 28, 2011 at 1:07 AM, khaled danwar<br>
&lt;<a href="mailto:khaled.danwar53@gmail.com">khaled.danwar53@gmail.com</a>&gt; wrote:<br>
&gt; Hello,<br>
&gt; I wasn&#39;t not sure if this request for help was better suited for itk users<br>
&gt; or vtk users, so I just went with itk since most of my code uses itk,<br>
&gt; hopefully nobody objects and I could still get help from any of you<br>
&gt; (including vtk users).<br>
&gt; The lay out of the land is this:<br>
&gt; 1) for each dicom image I use the confidence connected image filter from itk<br>
&gt; to employ a region based segmentation. Note that I do this for each image in<br>
&gt; turn (ie click on seed points on original image, get it segmented, save the<br>
&gt; file as a new dicom file in a folder) becasue I simply need to for this<br>
&gt; particular project.<br>
&gt; 2) once I have all my segmented dicom files in that folder, I intend to<br>
&gt; (more like &#39;need to&#39;) use the marching cubes algorithm given by vtk so that<br>
&gt; I can render a 3D image of the skull (I&#39;m segmenting ct scans to get the<br>
&gt; bones alone). This is where my problem is.<br>
&gt; For this particular 3d Rendering, my code looks a little something like<br>
&gt; this:<br>
&gt;<br>
&gt; //Load the data<br>
&gt; vtkSmartPointer&lt;vtkDICOMImageReader&gt; reader =<br>
&gt; vtkSmartPointer&lt;vtkDICOMImageReader&gt;::New();<br>
&gt; reader-&gt;SetDirectoryName(outputDirectory.c_str());<br>
&gt; reader-&gt;Update();<br>
&gt; //Smoothing the edges with gaussian<br>
&gt; vtkSmartPointer&lt;vtkImageGaussianSmooth&gt; gaussianSmoothFilter =<br>
&gt; vtkSmartPointer&lt;vtkImageGaussianSmooth&gt;::New();<br>
&gt; gaussianSmoothFilter-&gt;SetInputConnection(reader-&gt;GetOutputPort());<br>
&gt; gaussianSmoothFilter-&gt;SetRadiusFactor(2);<br>
&gt; //Marching Cubes<br>
&gt; vtkSmartPointer&lt;vtkMarchingCubes&gt; surface =<br>
&gt; vtkSmartPointer&lt;vtkMarchingCubes&gt;::New();<br>
&gt; surface-&gt;SetInputConnection(gaussianSmoothFilter-&gt;GetOutputPort());<br>
&gt; surface-&gt;ComputeNormalsOn();<br>
&gt; surface-&gt;ComputeGradientsOn();<br>
&gt; //surface-&gt;SetInputConnection(reader-&gt;GetOutputPort());<br>
&gt; //Create a mapper<br>
&gt; vtkSmartPointer&lt;vtkPolyDataMapper&gt; mapper =<br>
&gt; vtkSmartPointer&lt;vtkPolyDataMapper&gt;::New();<br>
&gt; mapper-&gt;SetInputConnection(surface-&gt;GetOutputPort());<br>
&gt; // Visualize<br>
&gt; vtkSmartPointer&lt;vtkActor&gt; actor = vtkSmartPointer&lt;vtkActor&gt;::New();<br>
&gt; actor-&gt;SetMapper(mapper);<br>
&gt; vtkSmartPointer&lt;vtkRenderer&gt; renderer =<br>
&gt; vtkSmartPointer&lt;vtkRenderer&gt;::New();<br>
&gt;<br>
&gt; vtkSmartPointer&lt;vtkRenderWindow&gt; renderWindow =<br>
&gt; vtkSmartPointer&lt;vtkRenderWindow&gt;::New();<br>
&gt; renderWindow-&gt;AddRenderer(renderer);<br>
&gt; vtkSmartPointer&lt;vtkRenderWindowInteractor&gt; interactor =<br>
&gt; vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;::New();<br>
&gt; interactor-&gt;SetRenderWindow(renderWindow);<br>
&gt; renderer-&gt;AddActor(actor);<br>
&gt;<br>
&gt; renderWindow-&gt;SetSize(800,600);<br>
&gt; renderWindow-&gt;Render();<br>
&gt; interactor-&gt;Start();<br>
&gt;<br>
&gt; The problem is that the marching cubes algorithm is complaining that the<br>
&gt; dicom files holding the segmented images are not of 3D format and so it cant<br>
&gt; render an output that I need. So can anyone help me sort out my need to use<br>
&gt; vtk marching cubes algorithm after I&#39;ve used itk segmentation on multiple<br>
&gt; files in turn.<br>
&gt; Thanks for any help,<br>
&gt; Khaled<br>
</div></div>&gt; _____________________________________<br>
&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;<br>
&gt; Visit other Kitware open-source projects at<br>
&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;<br>
&gt; Kitware offers ITK Training Courses, for more information visit:<br>
&gt; <a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
&gt;<br>
&gt; Please keep messages on-topic and check the ITK FAQ at:<br>
&gt; <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
&gt;<br>
&gt; Follow this link to subscribe/unsubscribe:<br>
&gt; <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
&gt;<br>
&gt;<br>
</blockquote></div><br></div>