From: ntfreddy Ntawiniga on
"David Doria" <daviddoria(a)gmail.com> wrote in message <gfhfj5$ih1$1(a)fred.mathworks.com>...
> I have missing something with Matlab's image transformation functions:
>
> I have an image "im" and transform it using
> im_out = imtransform(im, xform);
>
> When I imshow(im) and imshow(im_out), they are as I expect
>
> However, when I
> test = tformfwd(xform, 1, 1)
> I though I should get the coordinates in im_out where the point 1,1 in "im" was mapped. Instead, I get (-93, -9.8), which are clearly not image coordinates, as they are negative!!
>
> How would I see where the point 1,1 in im lands in im_out?
>
> Thanks,
>
> Dave

It is not test = tformfwd(xform, 1, 1)
it is test = tformfwd([1 1],xform)
From: Rob Comer on
> I have an image "im" and transform it using
> im_out = imtransform(im, xform);
>
> When I imshow(im) and imshow(im_out), they are as I expect
>
> However, when I
> test = tformfwd(xform, 1, 1)
> I though I should get the coordinates in im_out where the point 1,1 in "im" was mapped. Instead, I get (-93, -9.8), which are clearly not image coordinates, as they are negative!!

By default, imtransform "follows" your input image wherever your tform takes it. Why? Because you can easily make up a tform that move your whole image out of the first quadrant, and if that happened you'd get a useless, blank output. Other, equally perplexing scenarios are easy to invent.

Try overriding this default by supplying the optional parameters 'XData' and 'YData', like this:

im_out_clamped = imtransform(im, xform, ...
'XData', [1 size(im,2)],'YData', [1 size(im,1)]

and compare. I'd expect that you'll find that the (1,1) pixel from the original image is now missing, having moved out of sight to (-93, -9.8).

You can learn more from this example:

http://www.mathworks.com/access/helpdesk/help/toolbox/images/f12-23518.html

Good luck,

Rob Comer
Mapping Toolbox Development
The MathWorks, Inc.
 | 
Pages: 1
Prev: MTF, NPS
Next: set uitable with struct data