[vtkusers] Question about the accuracy of vtkMarchingSquares

Anja Ende anja.ende at googlemail.com
Sun Apr 6 18:41:05 EDT 2008


Hi everyone,

I am using vtkMarchingSquares to generate contours from a binary input image.

The code is roughly as follows:

vtkMarchingSquares * mc = vtkMarchingSquares::New();
double * range = input->GetScalarRange();
mc->SetInput(input);
mc->GenerateValues(1, 255, 255);
mc->Update();
		
vtkStripper * stripper = vtkStripper::New();
stripper->SetInput(mc->GetOutput());
stripper->Update();
	
vtkPolyData * polyData = vtkPolyData::New();
polyData->SetPoints(stripper->GetOutput()->GetPoints());
polyData->SetPolys(stripper->GetOutput()->GetLines());

vtkCellArray * ca = polyData->GetPolys();
ca->InitTraversal();
	
vtkIdType npts;
vtkIdType *pts;
	
vtkPoints * polyPoints = polyData->GetPoints();

And now I traverse this polydata object to get the points. So, what I
am interested in is creating the boundary of this mask on top of
another image. Now, I was expecting some rounding errors but I thought
the error should be within a pixel. However, I found much larger
shifts (sometimes 2- 3 pixels) between the object boundary and the
corresponding point returned by the marching squares algorithm.

Has anyone else noticed this and have any idea on what might be going on here?

Cheers,
Anja



More information about the vtkusers mailing list