Hi, <br><br>We're facing the same problem here for the evaluation of a liver segmentation algorithm. In order to reconstruct a surface from some manually selected points, we've tried :<br>- vtkDelaunay3D : works very bad in our case <br>
- vtkSurfaceReconstructionFilter : can reconstruct a surface from unorganized points, but the result isn't very good in my opinion, some points are ignored or moved ...<br>- vtkPowerCrustSurfaceReconstruction (not official find it here : <a href="http://www.sq3.org.uk/powercrust/">http://www.sq3.org.uk/powercrust/</a>) gives better result, but it is still buggy sometimes<br>
<br>- now we're using a home made solution following these steps :<br> - spline interpolation for each contour<br> - build a 2D binary image for each contour with 1 inside the spline, and 0 outside<br> - append all the 2D images<br>
- marchingcubes ...<br><br>But it is "de la cuisine"<br><br>Does anyone know a (vtk) way to build a surface from several 2D contours (vtkParametricSpline in our case) ?<br>Thanks<br><br><br><div class="gmail_quote">
On Wed, Apr 23, 2008 at 5:08 PM, Carsten Barkow <<a href="mailto:carsten.barkow@googlemail.com">carsten.barkow@googlemail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
<br>
we've implemented a 3D segmentation algorithm and want to evaluate it. Due to this we get some manual segmented data, but those are only 2D contours for each section of the volume. So we want to generate a 3D surface from this contours.<br>
In VTK there are classes for this purpose like vtkVoxelContoursToSurface or vtkRuledSurfaceFilter. Unfortunately we can not make it show us a surface. Has anybody an idea where the fault is? Here is the code:<br>
<br>
vtkPoints *points = vtkPoints::New();<br>
vtkCellArray *cells = vtkCellArray::New();<br>
int index = 0;<br>
int temp;<br>
VoxelXYZ v;<br>
double x, y, z;<br>
std::vector<VoxelXYZ> contour;<br>
// --- writing points and lines ----------------------------------------------------------------<br>
for(int sec = 0; sec < borderPoints->getZRes(); ++sec){<br>
if(borderPoints->getContour(sec, contour)){<br>
//remember first point index of actual contour temp = index;<br>
for(std::vector<VoxelXYZ>::iterator it = contour.begin(); it!=contour.end(); ++it){<br>
v = *it;<br>
x = static_cast<double>(v.getX());<br>
y = static_cast<double>(v.getY());<br>
z = static_cast<double>(v.getZ());<br>
points->InsertPoint(index, v.getX(), v.getY(), v.getZ());<br>
vtkLine *line = vtkLine::New();<br>
line->GetPointIds()->SetId(0, index);<br>
if((index-temp) == contour.size()-1)<br>
//reached last point of actual contour and close contour<br>
line->GetPointIds()->SetId(1, temp);<br>
else<br>
line->GetPointIds()->SetId(1, index+1);<br>
cells->InsertNextCell(line);<br>
line->Delete();<br>
++index;<br>
}<br>
}<br>
}<br>
// --------------------------------------------------------------------------------------------<br>
// Insert points and cells<br>
vtkPolyData *pointCloud = vtkPolyData::New();<br>
pointCloud->SetPoints(points);<br>
pointCloud->SetPolys(cells); // it also doesn't work with pointCloud->SetLines(cells);<br>
<br>
// --- just show contours for testing and this works fine we guess --------------------------------------<br>
vtkPolyDataMapper *contourMapper = vtkPolyDataMapper::New();<br>
contourMapper->SetInput(pointCloud);<br>
vtkActor *contourActor = vtkActor::New();<br>
contourActor->SetMapper(contourMapper);<br>
contourActor->GetProperty()->SetColor(1, 0, 0);<br>
contourActor->GetProperty()->SetAmbient(1);<br>
contourActor->GetProperty()->SetDiffuse(0);<br>
contourActor->GetProperty()->SetRepresentationToWireframe();<br>
renSurface->AddActor(contourActor);<br>
contourMapper->Delete();<br>
contourActor->Delete();<br>
// ------------------------------------------------------------------------------------------------<br>
<br>
// vtkRuledSurfaceFilter approach<br>
/*vtkRuledSurfaceFilter *ruledSurfaceFilter = vtkRuledSurfaceFilter::New();<br>
ruledSurfaceFilter->SetInput(pointCloud);<br>
ruledSurfaceFilter->CloseSurfaceOn();*/<br>
// vtkVoxelContoursToSurfaceFilter approach<br>
vtkVoxelContoursToSurfaceFilter *contourToSurfaceFilter = vtkVoxelContoursToSurfaceFilter::New();<br>
contourToSuraceFilter->SetInput(pointCloud);<br>
vtkPolyDataMapper *surfaceMapper = vtkPolyDataMapper::New();<br>
//surfaceMapper->SetInputConnection(ruledSurfaceFilter->GetOutputPort());<br>
surfaceMapper->SetInputConnection(contourToSurfaceFilter->GetOutputPort());<br>
vtkActor *surfaceActor = vtkActor::New();<br>
surfaceActor->SetMapper(surfaceMapper);<br>
surfaceActor->GetProperty()->SetDiffuseColor(1.0000, 0.3882, 0.2784);<br>
surfaceActor->GetProperty()->SetSpecularColor(1, 1, 1);<br>
surfaceActor->GetProperty()->SetSpecular(.4);<br>
surfaceActor->GetProperty()->SetSpecularPower(50);<br>
renSurface->AddActor(surfaceActor);<br>
points->Delete();<br>
cells->Delete();<br>
pointCloud->Delete();<br>
surfaceMapper->Delete();<br>
surfaceActor->Delete();<br>
renSurface->Delete();<br>
<br>
***thx for any hints/help***<br>
_______________________________________________<br>
This is the private VTK discussion list.<br>
Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><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>
</blockquote></div><br><br clear="all"><br>-- <br>------------------------------------------------------------------<br>Simon Esneault<br>Laboratoire Traitement du Signal et de l'Image, (LTSI, UMR-INSERM 642)<br>Université de Rennes I, Campus de Beaulieu, <br>
35042 Rennes Cedex, France.<br>Tel : +33 (0)6 64 61 30 94<br>Mail : <a href="mailto:simon.esneault@univ-rennes1.fr">simon.esneault@univ-rennes1.fr</a><br>------------------------------------------------------------------