[vtkusers] Molding an image slice

David Gobbi david.gobbi at gmail.com
Thu Apr 6 00:13:41 EDT 2017


On Wed, Apr 5, 2017 at 5:23 AM, Shark <m.nunes at fratoria.com> wrote:

>
> However, when the I pass the texture to the actor, it seems that the
> texture
> is not well mapped to the plane. This is very noticeable in some corners of
> the image where the texture is simply cut, because the plane is retracted
> in
> that corner. So, instead of the color texture being molded to the deformed
> plane, it is simply applied on top of it without any other consideration.
>

If the parts of the plane are folded back, then you might have to use either
vtkGridTransform or vtkBSplineTransform, instead of using vtkWarpVector.

Another thing I have noticed is when I set up the resolution of the plane, I
> have to reduce a unit from its dimensions, so I can match the number of
> points in the displacement field:
>

The resolution of the vtkPlaneSource is the number of facets (little
squares)
that make up the plane.  It's basic math that the number of points will be
the
number of facets plus one.

The texture coords are associated with the points, so you have two options:
you can set the number of facets to be equal to the number of pixels in your
image, and then map the texture coords to the corners of your pixels.  Or
you
can set the number of points to be equal to the number of pixels, and map
the texture coords to the centers of your pixels.  Both of these methods is
perfectly valid (you just have to be sure that you set the texture coords
correctly).

Also, remember that in texture coordinates, the position (0,0) is at the
corner
of the first texel, whereas in image coordinates, the origin is at the
center of
the first pixel.

Another thing I have noticed is that when I am setting the vtkDoubleArray to
> pass to the warpVector, if I set 3 components, and set the Z, there is a
> crazy behavior of how the texture is applied to the plane. With the Z
> coordinate, things get strange and the texture gets randomly inverted X <->
> Y in different slices.
>

You might have better luck applying the transformation with vtkGridTransform
and vtkTransformPolyDataFilter.  The vtkGridTransform expects a vector image
as its input, i.e. an image where each pixel is a displacement vector
(dx,dy,dz).

 - David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170405/a187b0a9/attachment.html>


More information about the vtkusers mailing list