[vtkusers] Inclusiveness of Rasterization

David Gobbi david.gobbi at gmail.com
Mon Jul 14 17:54:24 EDT 2014


Hi Bryan,

Thanks for the follow-up.  Actually, I looked through the code and the
tolerance is only properly applied in the X direction.  But as for
whether 0.5 would be enough (assuming that it was applied uniformly in
all directions), it should be because you just have to be sure that
the _center_ of the voxel is within the contour, so if the contour is
e.g. a square contour with its corners at exact pixel locations, even
a very small tolerance should be enough to make sure that the centers
of all voxels are within the stencil.

About the streaking, in fact I know how to change the algorithm to fix
that, and I've been trying to find time to further develop my
segmentation tools, of which vtkPolyDataToImageStencil is a part.
Unfortunately, I doubt that I'll be able to get started on it until
the fall.

 - David

On Mon, Jul 14, 2014 at 2:15 PM, Bryan Cool <bryan at radialogica.com> wrote:
> Thanks for the suggestion and apologies for the delay, David.  Are you sure
> that a tolerance of 0.5 should be enough?  Wouldn't a lower end contour
> intersecting a pixel .75 of the way across still be missed with 0.5, since
> {floor(.75 - .5) + 1} is 1?
>
>
>
> I tried tolerance values of 0.5 and 1.0 but unfortunately got the infamous
> streaking artifacts with both, so now I'm keeping the default tolerance and
> instead piping the output stencil image data through
> vtkImageContinuousDilate3D with a kernel size of (3,3,1).  That seems to
> give me the coverage I'm looking for without any artifacts.
>
>
>
> Thanks again,
>
> Bryan
>
>
>
> From: David Gobbi [mailto:david.gobbi at gmail.com]
> Sent: Wednesday, July 2, 2014 4:17 PM
>
>
> To: Bryan Cool
> Cc: VTK Users
> Subject: Re: [vtkusers] Inclusiveness of Rasterization
>
>
>
> Have you tried adjusting the Tolerance on vtkPolyDataToImageStencil?
>
> You can try setting it to a large value like 0.5, which gives half a pixel
>
> in tolerance.  That should guarantee that the contour is fully inside of
>
> the result.
>
>
>
>   David
>
>
>
> On Wed, Jul 2, 2014 at 2:46 PM, Bryan Cool <bryan at radialogica.com> wrote:
>
> Thanks for the quick reply, David.  You're right: I'm in need of inclusivity
> on both ends.  I'm voxelizing contours using vtkPolyDataToImageStencil and I
> want to ensure that the resulting stencil fully encapsulates the contours.
> Are there any tricks to compensate that wouldn't require me to modify my
> points directly?  I guess I could just dilate my result, but it would be
> nice to have it as tight around the contours as possible.
>
>
>
> Thanks,
>
> Bryan
>
>
>
> From: David Gobbi [mailto:david.gobbi at gmail.com]
> Sent: Wednesday, July 2, 2014 2:50 PM
> To: Bryan Cool
> Cc: VTK Users
> Subject: Re: [vtkusers] Inclusiveness of Rasterization
>
>
>
> Hi Bryan,
>
>
>
> Do you mean inclusive on both ends?  Exclusive on both ends would
>
> just make it worse...
>
>
>
> The behavior of the rasterization is 100% intentional.  In order for
>
> rasterization to work when there are adjacent areas that are being
>
> rasterized, it must be exclusive on one end and inclusive on the
>
> other end.  Otherwise, adjacent areas could end up with either a
>
> gap between them or with an overlap.
>
>
>
> The exclusitivity can be compensated for by subtracting a small
>
> tolerance at the lower end or by using other tricks.
>
>
>
> What is your use case?
>
>
>
>   - David
>
>
>
>
>
> On Wed, Jul 2, 2014 at 1:18 PM, Bryan Cool <bryan at radialogica.com> wrote:
>
> Hi everyone,
>
> I noticed that vtkImageStencilRaster has code like the following in
> InsertLine and FillStencilData, for both the x and y directions:
>
> if (x1 >= xmin)
>      {
>      r1 = vtkMath::Floor(x1) + 1;
>      }
> if (x2 < xmax)
>      {
>      r2 = vtkMath::Floor(x2);
>      }
>
> Correct me if I'm wrong, but it looks like the lower side is exclusive,
> while the upper end is inclusive.  The upshot of this is that the only way
> to stencil the first pixel is to have a line intersect the row on the
> negative side of the first pixel (in the extents).  On the other hand, to
> stencil the last pixel a line only need intersect anywhere past the
> second-to-last pixel (in the extents).
>
> Assuming that's true, it seems a bit asymmetric.  Is there any way to have
> exclusive behavior on both ends?
>
> Thanks,
> Bryan
>
>


More information about the vtkusers mailing list