I have very complex polydata and when I use vtkPolyDataToImageStencil -&gt; vtkImageStencil my ImageData contains much noise. I fixed it by vtkImplicitPolyData -&gt; vtkImplicitFunctionToImageStencil -&gt; vtkImageStencil, but now the whole process is very slow. How I can fix my polydata to work with the first solution? Or, how to speed up vtkImplicitFunctionToImageStencil?<br clear="all">

<br>(vtk 5.6.1)<br><br>vtkImageData *whiteImage = vtkImageData::New();    <br>  double bounds[6];<br>  polyData-&gt;GetBounds(bounds);<br>  double spacing[3];<br>  spacing[0] = 0.03;<br>  spacing[1] =  0.03;<br>  spacing[2] =  0.03;<br>

  whiteImage-&gt;SetSpacing(spacing);<br> <br><br>  int dim[3];<br>  for (int i = 0; i &lt; 3; i++)<br>    {<br>    dim[i] = static_cast&lt;int&gt;(ceil((bounds[i * 2 + 1] - bounds[i * 2]) / spacing[i]));<br>    }<br><br>

  whiteImage-&gt;SetDimensions(dim);<br>  whiteImage-&gt;SetExtent(0, dim[0] - 1, 0, dim[1] - 1, 0, dim[2] - 1);<br> <br>  double origin[3];<br><br>  origin[0] = bounds[0] + spacing[0] / 2;<br>  origin[1] = bounds[2] + spacing[1] / 2;<br>

  origin[2] = bounds[4] + spacing[2] / 2;<br>  whiteImage-&gt;SetOrigin(origin);<br> <br>  whiteImage-&gt;SetScalarTypeToUnsignedShort();<br>  whiteImage-&gt;AllocateScalars();<br> <br>  unsigned short inval = 255;<br>  unsigned short outval = 0;<br>

  vtkIdType count = whiteImage-&gt;GetNumberOfPoints();<br>  <br>  for (vtkIdType i = 0; i &lt; count; ++i)<br>  {<br>    whiteImage-&gt;GetPointData()-&gt;GetScalars()-&gt;SetTuple1(i, inval);<br>  }<br> <br>/*  <br>  vtkPolyDataToImageStencil *pol2stenc = vtkPolyDataToImageStencil::New();<br>

  pol2stenc-&gt;SetInput(polyData);<br>  pol2stenc-&gt;SetOutputOrigin(origin);<br>  pol2stenc-&gt;SetOutputSpacing(spacing);<br>  pol2stenc-&gt;SetOutputWholeExtent(whiteImage-&gt;GetExtent());<br>  pol2stenc-&gt;Update();<br>

*/<br><br>  vtkImplicitFunctionToImageStencil *func2stenc = vtkImplicitFunctionToImageStencil::New();<br>  func2stenc-&gt;SetThreshold(0.1);<br>
  func2stenc-&gt;SetInput(polyData);<br>
  func2stenc-&gt;SetOutputOrigin(origin);<br>
  func2stenc-&gt;SetOutputSpacing(spacing);<br>
  func2stenc-&gt;SetOutputWholeExtent(whiteImage-&gt;GetExtent());<br>
  func2stenc-&gt;Update();<br> <br>  vtkImageStencil *imgstenc = vtkImageStencil::New();<br>  imgstenc-&gt;SetInput(whiteImage);<br>  imgstenc-&gt;SetStencil(pol2stenc-&gt;GetOutput());<br>  imgstenc-&gt;ReverseStencilOff();<br>

  imgstenc-&gt;SetBackgroundValue(outval);<br>  imgstenc-&gt;Update();<br><br>-- <br>&quot;If you build your empire on money, it&#39;ll fall like a house of cards, if you build it on love, you&#39;ve built Taj Mahal!&quot; - Mark Hartmaier<br>

<br>