image and points transformation in Matlab
- From: Giff <giffnews@xxxxxxxxxxxxxxxxx>
- Date: Mon, 29 Jun 2009 11:58:20 +0200
Hi all,
I have successfully applied an affine transformation to an image thanks
to the "imtransform" and "maketform" functions in Matlab.
The transformation matrix in my case just includes scale and rotation.
I compute the transformation matrix from some point coordinates on the original image: the idea is to modify the image so that some of these landmarks are aligned and have a specific distance between each other.
So, I have n 2D points on the original image, I extract the transformation matrix from two of them and apply it to the image, achieving a result that looks good.
What I now need to do is to transform all these points so that they will match the same image feature in the transformed image, but I can't seem to manage.
I thought that I should just multiply each point by the transformation matrix, but that did not work.
Any hints?
Follows a code snippet, showing what I am trying to do.
pts is a 2xn array with the 2D point coordinates.
t_matrix = [s*cos(angle_rad) s*sin(angle_rad) 0; -s*sin(angle_rad)
s*cos(angle_rad) 0; 0 0 1];
tform = maketform('affine', t_matrix);
aligned_image = imtransform(image, tform, 'bilinear');
%transform to homogeneous coordinates and project
for i=1:size(pts,2)
homo_pt = [pts(:,i); 1];
new_pt = t_matrix' * homo_pt;
pts(:,i) = new_pt(1:2);
end
.
- Follow-Ups:
- Re: image and points transformation in Matlab
- From: Bob Alvarez
- Re: image and points transformation in Matlab
- Prev by Date: Re: Discovering rotation degree
- Next by Date: Re: advice about finding tooth in images
- Previous by thread: ★paypal payment★ discount aaa quality ralph lauren polo t shirts(www.guoshitrade.com) ☸☸☸☸☸☸
- Next by thread: Re: image and points transformation in Matlab
- Index(es):