Problem with imtransform and tformfwd image processing toolbox

5 views (last 30 days)
Hi all,
I have a question about the implementation of imtransform and tformfwd. In my assignment I have to stitch two images together using maketform, tformfwd and imtransform (I'm not allowed to use other Matlab functions).
So far I made a tform that makes the spatial transform structure, here p1 is my fixed image and p2 the moving image;
tform=maketform('projective',p2,p1);
Then I'm asked to use tformfwd to determine the corners of the moving image to find out which space should be reserved such that the space is large enough to contain both the moving and fixed image. I used:
[xm,ym]=tformfwd(tform,p2(:,1),p2(:,2));
Finally I have to use the function imtransform to implement to actual spatial transformation. I have to use XData and YData options, which I believe are the xm and ym coordinates that I get from the tformfwd function. But I am not sure if i used this correctly.
J=imtransform(im2,tform,'XData',[min(xm) max(xm)],'YData',[min(ym) max(ym)],'XYScale',1);
The coordinates of my control points are: u = [571.5 339.5 185.5 79.5]'; v = [649.5 1173.5 665.5 1571.5]'; x = [1147.5 883.5 757.5 585.5]'; y = [649.5 1177.5 659.5 1597.5]'; (where u and v are in p2 and x and y in my fixed image p1)
My question is, what am I doing wrong? I followed all the instructions in the documentation, but my transformed image looks like a cropped version of the original image. This probably was caused by the XData and YData inputs. How do I use these inputs correctly or did I do something wrong in the tformfwd function?
Help is much appreciated, Thanks in advance, Anne

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!