[vtkusers] vtkPolyDataToImageStencil with partial volume

Bill Lorensen bill.lorensen at gmail.com
Thu Feb 24 11:53:25 EST 2011


Definitely set the isovalue to .5 if you have binary 0/1 images.

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



More information about the vtkusers mailing list