[vtkusers] surface from contours
Simon ESNEAULT
simon.esneault at gmail.com
Wed Apr 23 12:35:10 EDT 2008
Hi,
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 :
- vtkDelaunay3D : works very bad in our case
- vtkSurfaceReconstructionFilter : can reconstruct a surface from
unorganized points, but the result isn't very good in my opinion, some
points are ignored or moved ...
- vtkPowerCrustSurfaceReconstruction (not official find it here :
http://www.sq3.org.uk/powercrust/) gives better result, but it is still
buggy sometimes
- now we're using a home made solution following these steps :
- spline interpolation for each contour
- build a 2D binary image for each contour with 1 inside the spline,
and 0 outside
- append all the 2D images
- marchingcubes ...
But it is "de la cuisine"
Does anyone know a (vtk) way to build a surface from several 2D contours
(vtkParametricSpline in our case) ?
Thanks
On Wed, Apr 23, 2008 at 5:08 PM, Carsten Barkow <
carsten.barkow at googlemail.com> wrote:
> Hi,
>
> 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.
> 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:
>
> vtkPoints *points = vtkPoints::New();
> vtkCellArray *cells = vtkCellArray::New();
> int index = 0;
> int temp;
> VoxelXYZ v;
> double x, y, z;
> std::vector<VoxelXYZ> contour;
> // --- writing points and lines
> ----------------------------------------------------------------
> for(int sec = 0; sec < borderPoints->getZRes(); ++sec){
> if(borderPoints->getContour(sec, contour)){
> //remember first point index of actual contour
> temp = index;
> for(std::vector<VoxelXYZ>::iterator it = contour.begin();
> it!=contour.end(); ++it){
> v = *it;
> x = static_cast<double>(v.getX());
> y = static_cast<double>(v.getY());
> z = static_cast<double>(v.getZ());
> points->InsertPoint(index, v.getX(), v.getY(),
> v.getZ());
> vtkLine *line = vtkLine::New();
> line->GetPointIds()->SetId(0, index);
> if((index-temp) == contour.size()-1)
> //reached last point of actual contour and close
> contour
> line->GetPointIds()->SetId(1, temp);
> else
> line->GetPointIds()->SetId(1, index+1);
> cells->InsertNextCell(line);
> line->Delete();
> ++index;
> }
> }
> }
> //
> --------------------------------------------------------------------------------------------
> // Insert points and cells
> vtkPolyData *pointCloud = vtkPolyData::New();
> pointCloud->SetPoints(points);
> pointCloud->SetPolys(cells); // it also doesn't work with
> pointCloud->SetLines(cells);
>
> // --- just show contours for testing and this works fine we guess
> --------------------------------------
> vtkPolyDataMapper *contourMapper = vtkPolyDataMapper::New();
> contourMapper->SetInput(pointCloud);
> vtkActor *contourActor = vtkActor::New();
> contourActor->SetMapper(contourMapper);
> contourActor->GetProperty()->SetColor(1, 0, 0);
> contourActor->GetProperty()->SetAmbient(1);
> contourActor->GetProperty()->SetDiffuse(0);
> contourActor->GetProperty()->SetRepresentationToWireframe();
> renSurface->AddActor(contourActor);
> contourMapper->Delete();
> contourActor->Delete();
> //
> ------------------------------------------------------------------------------------------------
>
> // vtkRuledSurfaceFilter approach
> /*vtkRuledSurfaceFilter *ruledSurfaceFilter =
> vtkRuledSurfaceFilter::New();
> ruledSurfaceFilter->SetInput(pointCloud);
> ruledSurfaceFilter->CloseSurfaceOn();*/
> // vtkVoxelContoursToSurfaceFilter approach
> vtkVoxelContoursToSurfaceFilter *contourToSurfaceFilter =
> vtkVoxelContoursToSurfaceFilter::New();
> contourToSuraceFilter->SetInput(pointCloud);
> vtkPolyDataMapper *surfaceMapper = vtkPolyDataMapper::New();
>
> //surfaceMapper->SetInputConnection(ruledSurfaceFilter->GetOutputPort());
>
> surfaceMapper->SetInputConnection(contourToSurfaceFilter->GetOutputPort());
> vtkActor *surfaceActor = vtkActor::New();
> surfaceActor->SetMapper(surfaceMapper);
> surfaceActor->GetProperty()->SetDiffuseColor(1.0000, 0.3882, 0.2784);
> surfaceActor->GetProperty()->SetSpecularColor(1, 1, 1);
> surfaceActor->GetProperty()->SetSpecular(.4);
> surfaceActor->GetProperty()->SetSpecularPower(50);
> renSurface->AddActor(surfaceActor);
> points->Delete();
> cells->Delete();
> pointCloud->Delete();
> surfaceMapper->Delete();
> surfaceActor->Delete();
> renSurface->Delete();
>
> ***thx for any hints/help***
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
--
------------------------------------------------------------------
Simon Esneault
Laboratoire Traitement du Signal et de l'Image, (LTSI, UMR-INSERM 642)
Université de Rennes I, Campus de Beaulieu,
35042 Rennes Cedex, France.
Tel : +33 (0)6 64 61 30 94
Mail : simon.esneault at univ-rennes1.fr
------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080423/37f65caf/attachment.htm>
More information about the vtkusers
mailing list