If that&#39;s the case, then maybe I could have issues on the other side (converting binary images to contours, I do both).  For this I&#39;m using vtkMarchingSquares followed by vtkStripper<div><br></div><div><div>int[] extent = binaryOrgan.GetExtent();</div>
<div>        switch (orientation) {</div><div>            case OrthoPanel.ORIENTATION_XY:</div><div>                extent[4] = slice;</div><div>                extent[5] = slice;</div><div>                break;</div><div>
            case OrthoPanel.ORIENTATION_XZ:</div><div>                extent[2] = slice;</div><div>                extent[3] = slice;</div><div>                break;</div><div>            case OrthoPanel.ORIENTATION_YZ:</div>
<div>                extent[0] = slice;</div><div>                extent[1] = slice;</div><div>                break;</div><div>        }</div></div><div><br></div><div><div>vtkMarchingSquares marching = new vtkMarchingSquares();</div>
<div>        marching.SetInput(binaryOrgan);</div><div>        marching.SetImageRange(extent);</div><div>        marching.SetValue(0, 1);</div><div>        marching.Update();</div><div>        vtkPolyData marchingOutput = marching.GetOutput();</div>
<div><br></div><div>        vtkStripper stripper = new vtkStripper();</div><div>        stripper.SetInput(marchingOutput);</div><div>        stripper.Update();</div><div><br></div><div>Does anything look like it could be causing my issues there?</div>
<br><div class="gmail_quote">On Wed, Feb 23, 2011 at 11:18 AM, David Gobbi <span dir="ltr">&lt;<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
The value &quot;1e-6&quot; is a common tolerance because it is larger than<br>
most roundoff errors that are likely to occur in the calculations,<br>
but still small enough that it won&#39;t appreciably increase size of the<br>
region.<br>
<br>
Setting the tolerance to zero does exactly what you noted.  If the<br>
pixel is exactly on the edge, then it is considered to be inside if the<br>
edge is a leading edge, or outside if the edge is a trailing edge.<br>
This is done so that if you have two contours which are adjacent<br>
(i.e. share an edge), the edge voxels will be considered to be in<br>
just one of the two contours instead of in both.  If the tolerance is<br>
set larger than zero, then the edge pixels would always be considered<br>
to be in both contours.<br>
<br>
If you are dealing with rectangular contours, then the contour<br>
lines should be made so that they lie halfway between pixels, instead<br>
of lying directly on top of the pixels.  Then there is no uncertainty<br>
about whether a pixel lies inside or outside.<br>
<font color="#888888"><br>
 - David<br>
</font><div><div></div><div class="h5"><br>
<br>
On Wed, Feb 23, 2011 at 11:58 AM, Jonathan Morra &lt;<a href="mailto:jonmorra@gmail.com">jonmorra@gmail.com</a>&gt; wrote:<br>
&gt; I had the tolerance set to 0, and setting it to 1e-6 didn&#39;t fix the problem.<br>
&gt;  How did you come up with that number?  What&#39;s wrong with setting it to 0?<br>
&gt;  In my case usually the left and top side of the vtkImageData is being<br>
&gt; eroded, such that if I call the filter many times, the vtkImageData will<br>
&gt; eventually be blank because it will all be eroded.   However, sometimes the<br>
&gt; bottom and right grow in size, I haven&#39;t figured out which situations cause<br>
&gt; which.<br>
&gt;<br>
&gt; On Wed, Feb 23, 2011 at 10:54 AM, David Gobbi &lt;<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi Jonathan,<br>
&gt;&gt;<br>
&gt;&gt; Whether a pixel is set depends on whether the center of the pixel<br>
&gt;&gt; is inside or outside the contour, irregardless of what proportion of<br>
&gt;&gt; the pixel&#39;s volume is inside or outside.<br>
&gt;&gt;<br>
&gt;&gt; The only adjustment is the Tolerance, which should be set to<br>
&gt;&gt; around 1e-6 so that pixels right on the edge of the contour<br>
&gt;&gt; are considered to be inside.  The tolerance cannot be negative.<br>
&gt;&gt;<br>
&gt;&gt;  - David<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Wed, Feb 23, 2011 at 11:22 AM, Jonathan Morra &lt;<a href="mailto:jonmorra@gmail.com">jonmorra@gmail.com</a>&gt;<br>
&gt;&gt; wrote:<br>
&gt;&gt; &gt; I am currently using vtkPolyDataToImageStencil to successfully convert<br>
&gt;&gt; &gt; contours represented as vtkPolyData to binary vtkImageData&#39;s.  However,<br>
&gt;&gt; &gt; I&#39;m<br>
&gt;&gt; &gt; noticing a problem with the output sometimes.  Sometimes the resulting<br>
&gt;&gt; &gt; binary images are slightly smaller or slightly bigger than the poly data<br>
&gt;&gt; &gt; they were made from.  I assume this is the result of partial volume<br>
&gt;&gt; &gt; effects.<br>
&gt;&gt; &gt;  I would like to know 2 things<br>
&gt;&gt; &gt; 1.  How does vtkPolyDataToImageStencil handle partial volume.<br>
&gt;&gt; &gt; 2.  Is there a way to tune partial volume in vtkPolyDataToImageStencil?<br>
&gt;&gt; &gt;  For<br>
&gt;&gt; &gt; instance, a parameter which says if the contour includes less than x<br>
&gt;&gt; &gt; percentage of the pixel then that pixel is 0.<br>
&gt;&gt; &gt; Thanks,<br>
&gt;&gt; &gt; Jon<br>
&gt;&gt; &gt; PS If my assumption about partial volume effects is wrong, please let me<br>
&gt;&gt; &gt; know.<br>
&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt; &gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Visit other Kitware open-source projects at<br>
&gt;&gt; &gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Please keep messages on-topic and check the VTK FAQ at:<br>
&gt;&gt; &gt; <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Follow this link to subscribe/unsubscribe:<br>
&gt;&gt; &gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br></div>