[vtkusers] perspective image transformation
David Gobbi
david.gobbi at gmail.com
Wed Aug 10 08:22:53 EDT 2011
Hi Martin,
You can reduce the distortion in the texture mapping by subdividing
the polygons. The finer the subdivision, the better the result. (For
more info see e.g. the Wikipedia page on texture mapping).
To warp an image before texture mapping, you can use vtkImageReslice
and vtkPerspectiveTransform. VTK always uses 4x4 matrices for
transformations, so you would have to insert 0010 as the third row and
column in order to create a 4x4 matrix from your 3x3 matrix. There is
nothing in VTK (as far as I know) to automatically compute the
perspective transformation from the two quadrangles.
- David
On Wed, Aug 10, 2011 at 4:25 AM, Affolter Martin <martin.affolter at ntb.ch> wrote:
> Hi vtk-users,
>
> I've been reading and experimenting with textures and how to map them on planar surfaces. The goal is to map a certain (sub-)area (e.g. quadrangle) from an image onto a planar polygon (also quadrangle), which I achieved so far by defining the normalized textureCoords for each point in the polygon. The problem I'm facing is that the resulting texture appears distorted. So here my two questions:
>
> 1. is there a way to apply a perspective image-transformation (conserving straight lines) before using the image for texturing? This way I imagine the distortion should disappear because the subimage and the polygon would have the same shape and ratio. (analogy in OpenCV: warpImage(...))
>
> 2. is there a class that calculates the perspective transformation matrix (3x3) from corresponding image-points? (analogy in OpenCV: getPerspectiveTransform(...))
>
> Any help or alternative suggestions are welcome.
>
> Thanks,
> Martin
>
> PS: I've attached my result. Not sure if it will come through...
More information about the vtkusers
mailing list