If that's the case, then maybe I could have issues on the other side (converting binary images to contours, I do both). For this I'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"><<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
The value "1e-6" 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'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 <<a href="mailto:jonmorra@gmail.com">jonmorra@gmail.com</a>> wrote:<br>
> I had the tolerance set to 0, and setting it to 1e-6 didn't fix the problem.<br>
> How did you come up with that number? What's wrong with setting it to 0?<br>
> In my case usually the left and top side of the vtkImageData is being<br>
> eroded, such that if I call the filter many times, the vtkImageData will<br>
> eventually be blank because it will all be eroded. However, sometimes the<br>
> bottom and right grow in size, I haven't figured out which situations cause<br>
> which.<br>
><br>
> On Wed, Feb 23, 2011 at 10:54 AM, David Gobbi <<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>> wrote:<br>
>><br>
>> Hi Jonathan,<br>
>><br>
>> Whether a pixel is set depends on whether the center of the pixel<br>
>> is inside or outside the contour, irregardless of what proportion of<br>
>> the pixel's volume is inside or outside.<br>
>><br>
>> The only adjustment is the Tolerance, which should be set to<br>
>> around 1e-6 so that pixels right on the edge of the contour<br>
>> are considered to be inside. The tolerance cannot be negative.<br>
>><br>
>> - David<br>
>><br>
>><br>
>> On Wed, Feb 23, 2011 at 11:22 AM, Jonathan Morra <<a href="mailto:jonmorra@gmail.com">jonmorra@gmail.com</a>><br>
>> wrote:<br>
>> > I am currently using vtkPolyDataToImageStencil to successfully convert<br>
>> > contours represented as vtkPolyData to binary vtkImageData's. However,<br>
>> > I'm<br>
>> > noticing a problem with the output sometimes. Sometimes the resulting<br>
>> > binary images are slightly smaller or slightly bigger than the poly data<br>
>> > they were made from. I assume this is the result of partial volume<br>
>> > effects.<br>
>> > I would like to know 2 things<br>
>> > 1. How does vtkPolyDataToImageStencil handle partial volume.<br>
>> > 2. Is there a way to tune partial volume in vtkPolyDataToImageStencil?<br>
>> > For<br>
>> > instance, a parameter which says if the contour includes less than x<br>
>> > percentage of the pixel then that pixel is 0.<br>
>> > Thanks,<br>
>> > Jon<br>
>> > PS If my assumption about partial volume effects is wrong, please let me<br>
>> > know.<br>
>> > _______________________________________________<br>
>> > Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>> ><br>
>> > Visit other Kitware open-source projects at<br>
>> > <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>> ><br>
>> > Please keep messages on-topic and check the VTK FAQ at:<br>
>> > <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
>> ><br>
>> > Follow this link to subscribe/unsubscribe:<br>
>> > <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
>> ><br>
>> ><br>
><br>
><br>
</div></div></blockquote></div><br></div>