Please post all of the code including all of the typedef's.<br><br><div class="gmail_quote">On Mon, Aug 29, 2011 at 1:01 PM, khaled danwar <span dir="ltr"><<a href="mailto:khaled.danwar53@gmail.com">khaled.danwar53@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;">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'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<InputPixelType,InputDimension><span style="white-space: pre-wrap;">        </span>InputImageType;</div><div>typedef itk::ImageFileReader<InputImageType><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->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->SetUseSeriesDetails( true );</div>
<div><span style="white-space: pre-wrap;">        </span>nameGenerator->SetInputDirectory( outputDirectory );</div><div><span style="white-space: pre-wrap;">        </span>//extraxt the filenames</div>
<div> SeriesIdContainer seriesUID = nameGenerator->GetSeriesUIDs();</div><div> FileNamesContainer fileNames = nameGenerator->GetFileNames( seriesUID.begin()->c_str() );</div><div><br></div><div> reader->SetFileNames( fileNames );</div>
<div><span style="white-space: pre-wrap;">        </span></div><div> try</div><div> {</div><div> reader->Update();</div><div> }</div><div> catch (itk::ExceptionObject &ex)</div><div> {</div>
<div> std::cout << ex << 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->SetInput( reader->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<vtkImageGaussianSmooth> gaussianSmoothFilter = vtkSmartPointer<vtkImageGaussianSmooth>::New(); </div><div><span style="white-space: pre-wrap;">        </span>gaussianSmoothFilter->SetInput(threshold->GetOutput());</div>
<div><span style="white-space: pre-wrap;">        </span>//gaussianSmoothFilter->SetInputConnection(vtkImporter->GetOutputPort()); </div><div><span style="white-space: pre-wrap;">        </span>gaussianSmoothFilter->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->SetInput(gaussianSmoothFilter->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<vtkDiscreteMarchingCubes> surface = vtkSmartPointer<vtkDiscreteMarchingCubes>::New(); </div>
<div><span style="white-space: pre-wrap;">        </span>surface->SetInput(toStructuredPoints->GetOutput());</div><div><span style="white-space: pre-wrap;">        </span>//surface->SetInputConnection(gaussianSmoothFilter->GetOutputPort());</div>
<div><span style="white-space: pre-wrap;">        </span>surface->ComputeNormalsOn();</div><div><span style="white-space: pre-wrap;">        </span>surface->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<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();</div>
<div><span style="white-space: pre-wrap;">        </span>mapper->SetInput(surface->GetOutput());</div><div><span style="white-space: pre-wrap;">        </span>mapper->SetInputConnection(surface->GetOutputPort());</div>
<div><br></div><div><span style="white-space: pre-wrap;">        </span>// Visualize</div><div><span style="white-space: pre-wrap;">        </span>vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();</div>
<div><span style="white-space: pre-wrap;">        </span>actor->SetMapper(mapper);</div><div><br></div><div><span style="white-space: pre-wrap;">        </span>vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New(); </div>
<div><span style="white-space: pre-wrap;">        </span>vtkSmartPointer<vtkRenderWindow> renderWindow = vtkSmartPointer<vtkRenderWindow>::New();</div><div><span style="white-space: pre-wrap;">        </span>vtkSmartPointer<vtkRenderWindowInteractor> interactor = vtkSmartPointer<vtkRenderWindowInteractor>::New(); </div>
<div><br></div><div><span style="white-space: pre-wrap;">        </span>renderer->AddActor(actor); </div><div><span style="white-space: pre-wrap;">        </span>renderWindow->AddRenderer(renderer); </div>
<div><span style="white-space: pre-wrap;">        </span>interactor->SetRenderWindow(renderWindow); </div><div><br></div><div><span style="white-space: pre-wrap;">        </span>renderWindow->SetSize(800,600); </div>
<div><span style="white-space: pre-wrap;">        </span>renderWindow->Render(); </div><div><span style="white-space: pre-wrap;">        </span>interactor->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>