Please post all of the code including all of the typedef&#39;s.<br><br><div class="gmail_quote">On Mon, Aug 29, 2011 at 1:01 PM, khaled danwar <span dir="ltr">&lt;<a href="mailto:khaled.danwar53@gmail.com">khaled.danwar53@gmail.com</a>&gt;</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;">Hello vtk users<div><br></div><div>The program I am writing has a mixture of itk and vtk procedures, my problem is when I make use of vtkMarchingCubes.</div>
<div><br></div><div>From my understanding, I can use vtkMarchingCubes to render a 3D image in the viewing window (and effectively interact with it).</div>
<div><br></div><div>I have a series of dicom files. I went through each and every one of them to select seeds for a region based segmentation procedure (itkConfidenceConnectedFilter), I then write segmented output into a new dicom file (I simply use itkImageWriter and filename to originalName.dcm and save it in another directory). The last task I need to do is to give a 3D visualisation of segmented dicom files (preferably using MarchingCubes). When I try the code below out, it complains about the files not being in 3D format when Im sure (I think Im sure, I&#39;m anew user to vtk and itk) I saved it in 3D format.</div>

<div><br></div><div><br></div><div>Code:</div><div><br></div><div><br></div><div><div>typedef float InputPixelType;</div><div>typedef unsigned short OutputPixelType;</div><div><br></div><div>//define the image type that will read from the input DICOM file</div>

<div>typedef itk::Image&lt;InputPixelType,InputDimension&gt;<span style="white-space: pre-wrap;">        </span>InputImageType;</div><div>typedef itk::ImageFileReader&lt;InputImageType&gt;<span style="white-space: pre-wrap;">        </span>ReaderType;</div>

</div><div><br></div><div><br></div><div><div><span style="white-space: pre-wrap;">        </span>//Load the data</div><div><span style="white-space: pre-wrap;">        </span>ReaderType3D::Pointer reader = ReaderType3D::New();</div>
<div><span style="white-space: pre-wrap;">        </span>//we need to make use of GDCMImageIO to assist with reading a series of DICOM files in a different directory</div><div><span style="white-space: pre-wrap;">        </span>ImageIOType::Pointer dicomReadIO = ImageIOType::New();</div>

<div><span style="white-space: pre-wrap;">        </span>reader-&gt;SetImageIO( dicomReadIO );</div><div><span style="white-space: pre-wrap;">        </span>//get the directory whilst instructing to make use of as much information to distinguish between DICOM files</div>

<div><span style="white-space: pre-wrap;">        </span>NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();</div><div><span style="white-space: pre-wrap;">        </span>nameGenerator-&gt;SetUseSeriesDetails( true );</div>

<div><span style="white-space: pre-wrap;">        </span>nameGenerator-&gt;SetInputDirectory( outputDirectory );</div><div><span style="white-space: pre-wrap;">        </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 style="white-space: pre-wrap;">        </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 style="white-space: pre-wrap;">        </span>ExportFilterType::Pointer itkExporter = ExportFilterType::New();</div>
<div><span style="white-space: pre-wrap;">        </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><br></div><div><span style="white-space: pre-wrap;">        </span>//Smoothing the edges with gaussian</div>

<div><span style="white-space: pre-wrap;">        </span>vtkSmartPointer&lt;vtkImageGaussianSmooth&gt; gaussianSmoothFilter = vtkSmartPointer&lt;vtkImageGaussianSmooth&gt;::New(); </div><div><span style="white-space: pre-wrap;">        </span>gaussianSmoothFilter-&gt;SetInput(threshold-&gt;GetOutput());</div>

<div><span style="white-space: pre-wrap;">        </span>//gaussianSmoothFilter-&gt;SetInputConnection(vtkImporter-&gt;GetOutputPort()); </div><div><span style="white-space: pre-wrap;">        </span>gaussianSmoothFilter-&gt;SetRadiusFactor(2); </div>

<div><br></div><div><span style="white-space: pre-wrap;">        </span>vtkImageToStructuredPoints </div><div>*toStructuredPoints=vtkImageToStructuredPoints::New();</div><div><span style="white-space: pre-wrap;">        </span> toStructuredPoints-&gt;SetInput(gaussianSmoothFilter-&gt;GetOutput());</div>

<div><br></div><div><span style="white-space: pre-wrap;">        </span>//Marching Cubes</div><div><span style="white-space: pre-wrap;">        </span>vtkSmartPointer&lt;vtkDiscreteMarchingCubes&gt; surface = vtkSmartPointer&lt;vtkDiscreteMarchingCubes&gt;::New(); </div>

<div><span style="white-space: pre-wrap;">        </span>surface-&gt;SetInput(toStructuredPoints-&gt;GetOutput());</div><div><span style="white-space: pre-wrap;">        </span>//surface-&gt;SetInputConnection(gaussianSmoothFilter-&gt;GetOutputPort());</div>

<div><span style="white-space: pre-wrap;">        </span>surface-&gt;ComputeNormalsOn();</div><div><span style="white-space: pre-wrap;">        </span>surface-&gt;ComputeGradientsOn();</div><div><br></div>
<div><span style="white-space: pre-wrap;">        </span>//Create a mapper</div><div><span style="white-space: pre-wrap;">        </span>vtkSmartPointer&lt;vtkPolyDataMapper&gt; mapper = vtkSmartPointer&lt;vtkPolyDataMapper&gt;::New();</div>

<div><span style="white-space: pre-wrap;">        </span>mapper-&gt;SetInput(surface-&gt;GetOutput());</div><div><span style="white-space: pre-wrap;">        </span>mapper-&gt;SetInputConnection(surface-&gt;GetOutputPort());</div>
<div><br></div><div><span style="white-space: pre-wrap;">        </span>// Visualize</div><div><span style="white-space: pre-wrap;">        </span>vtkSmartPointer&lt;vtkActor&gt; actor = vtkSmartPointer&lt;vtkActor&gt;::New();</div>
<div><span style="white-space: pre-wrap;">        </span>actor-&gt;SetMapper(mapper);</div><div><br></div><div><span style="white-space: pre-wrap;">        </span>vtkSmartPointer&lt;vtkRenderer&gt; renderer = vtkSmartPointer&lt;vtkRenderer&gt;::New(); </div>

<div><span style="white-space: pre-wrap;">        </span>vtkSmartPointer&lt;vtkRenderWindow&gt; renderWindow = vtkSmartPointer&lt;vtkRenderWindow&gt;::New();</div><div><span style="white-space: pre-wrap;">        </span>vtkSmartPointer&lt;vtkRenderWindowInteractor&gt; interactor = vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;::New(); </div>

<div><br></div><div><span style="white-space: pre-wrap;">        </span>renderer-&gt;AddActor(actor); </div><div><span style="white-space: pre-wrap;">        </span>renderWindow-&gt;AddRenderer(renderer); </div>
<div><span style="white-space: pre-wrap;">        </span>interactor-&gt;SetRenderWindow(renderWindow); </div><div><br></div><div><span style="white-space: pre-wrap;">        </span>renderWindow-&gt;SetSize(800,600); </div>
<div><span style="white-space: pre-wrap;">        </span>renderWindow-&gt;Render(); </div><div><span style="white-space: pre-wrap;">        </span>interactor-&gt;Start();</div></div><div><br></div><div><br>
</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div>Error:</div><div><br></div><div><span style="font-family: arial,sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);"><div>

ERROR: In C:.....\vtkMarchingCubes.cxx, line 415</div><div>vtkMarchingCubes (0000000002F58D40): Cannot contour data of dimension != 3</div><div><br></div><div><br></div><div><br></div><div>Any help would be appreciated including any insight on these vtk classes I may be using wrongly, Thanks.</div>

</span></div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br>