[vtkusers] vtkPolyDataToImageStencil with partial volume
David Gobbi
david.gobbi at gmail.com
Thu Feb 24 12:54:54 EST 2011
Look at the TracerWidget example that I mentioned.
On Thu, Feb 24, 2011 at 10:32 AM, Jonathan Morra <jonmorra at gmail.com> wrote:
> I've never used vtkTransformPolyDataFilter, how would I use that filter in
> my situation?
>
> On Thu, Feb 24, 2011 at 9:17 AM, David Gobbi <david.gobbi at gmail.com> wrote:
>>
>> Hi Jonathan,
>>
>> I still recommend that you add a vtkTransformPolyDataFilter like in the
>> ImageTracerWidget example. Right now your image slice is right on the
>> top edge of the extruded contour, so the smallest amount of roundoff error
>> might cause it to miss. By shifting the extruded contour up by half a
>> voxel,
>> you can preemptively guard against such errors.
>>
>> - David
>>
>>
>> On Thu, Feb 24, 2011 at 10:09 AM, Jonathan Morra <jonmorra at gmail.com>
>> wrote:
>> > Actually, after setting the marching squares value to 0.5 and changing
>> > the
>> > linear extrusion filter it's working now. Thanks!!!
>> >
>> > On Thu, Feb 24, 2011 at 9:02 AM, Bill Lorensen <bill.lorensen at gmail.com>
>> > wrote:
>> >>
>> >> Also, the stencil algorithm and marching squares use different
>> >> criteria to determine whether a "pixel" is inside or outside.
>> >>
>> >> For the stencil, the pixel is considered a point and checked within a
>> >> tolerance for inside/outside. I'm guessing here).
>> >> For marching squares, a "square" is composed of four pixels. If at
>> >> least one of the four pixels is of the opposite state(inside/outside)
>> >> then a contour will be generated.
>> >>
>> >> On Thu, Feb 24, 2011 at 11:53 AM, Bill Lorensen
>> >> <bill.lorensen at gmail.com>
>> >> wrote:
>> >> > 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