Hello,<div><br></div><div>I wasn't not sure if this request for help was better suited for itk users or vtk users, so I just went with itk since most of my code uses itk, hopefully nobody objects and I could still get help from any of you (including vtk users).</div>
<div><br></div><div>The lay out of the land is this:</div><div><br></div><div>1) for each dicom image I use the confidence connected image filter from itk to employ a region based segmentation. Note that I do this for each image in turn (ie click on seed points on original image, get it segmented, save the file as a new dicom file in a folder) becasue I simply need to for this particular project.</div>
<div><br></div><div>2) once I have all my segmented dicom files in that folder, I intend to (more like 'need to') use the marching cubes algorithm given by vtk so that I can render a 3D image of the skull (I'm segmenting ct scans to get the bones alone). This is where my problem is.</div>
<div><br></div><div>For this particular 3d Rendering, my code looks a little something like this:</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>vtkSmartPointer<vtkDICOMImageReader> reader = vtkSmartPointer<vtkDICOMImageReader>::New(); </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>reader->SetDirectoryName(outputDirectory.c_str()); </div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>reader->Update(); </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<vtkImageGaussianSmooth> gaussianSmoothFilter = vtkSmartPointer<vtkImageGaussianSmooth>::New(); </div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>gaussianSmoothFilter->SetInputConnection(reader->GetOutputPort()); </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>gaussianSmoothFilter->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<vtkMarchingCubes> surface = vtkSmartPointer<vtkMarchingCubes>::New(); </div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>surface->SetInputConnection(gaussianSmoothFilter->GetOutputPort());</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>surface->ComputeNormalsOn();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>surface->ComputeGradientsOn();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>//surface->SetInputConnection(reader->GetOutputPort());</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<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>mapper->SetInputConnection(surface->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<vtkActor> actor = vtkSmartPointer<vtkActor>::New();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>actor->SetMapper(mapper);</div>
<div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New(); </div><div> </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkRenderWindow> renderWindow = vtkSmartPointer<vtkRenderWindow>::New(); </div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>renderWindow->AddRenderer(renderer); </div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkRenderWindowInteractor> interactor = vtkSmartPointer<vtkRenderWindowInteractor>::New(); </div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>interactor->SetRenderWindow(renderWindow); </div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>renderer->AddActor(actor); </div>
<div> </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>renderWindow->SetSize(800,600); </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>renderWindow->Render(); </div><div>
<span class="Apple-tab-span" style="white-space:pre">        </span>interactor->Start(); </div></div><div><br></div><div><br></div><div>The problem is that the marching cubes algorithm is complaining that the dicom files holding the segmented images are not of 3D format and so it cant render an output that I need. So can anyone help me sort out my need to use vtk marching cubes algorithm after I've used itk segmentation on multiple files in turn.</div>
<div><br></div><div>Thanks for any help,</div><div>Khaled</div>