[vtkusers] Problem with vtkPolyDataToImageStencil

matheus_viana vianamp at gmail.com
Thu Jul 26 17:32:33 EDT 2012


Hello guys.

I've a polydata and I'd like to voxelize that in order to obtain an
ImageData. In order to do so, I'm using the following code:

 vtkImageData *blankImage = vtkImageData::New();
 blankImage -> SetExtent(extent);
 blankImage -> SetOrigin(0,0,0);
 blankImage -> SetSpacing(1,1,1);
 blankImage -> SetScalarTypeToUnsignedChar();
 blankImage -> AllocateScalars(); 

 vtkPolyDataToImageStencil *pol2Stenc = vtkPolyDataToImageStencil::New();
 pol2Stenc -> SetTolerance(0.5);
 pol2Stenc -> SetInput(myPolyData);
 pol2Stenc -> SetInformationInput(blankImage);
 pol2Stenc -> Update();

 vtkImageStencil *stencil = vtkImageStencil::New();
 stencil -> SetInput(blankImage);
 stencil -> ReverseStencilOff();
 stencil -> SetStencil(pol2Stenc->GetOutput());
 stencil -> Update();
 vtkImageData *image = stencil -> GetOutput();

It does the job, but I've observed some artifacts in the final image, as can
be seen in the attached picture.

Dos anyone have any idea about how to solve this problem? Is that a bug? Or
am I doing any stupid thing?

Cheers
Matheus

http://vtk.1045678.n5.nabble.com/file/n5714947/Viana-vtkPolyDataToImageStencil.jpg 



--
View this message in context: http://vtk.1045678.n5.nabble.com/Problem-with-vtkPolyDataToImageStencil-tp5714947.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list