0

I am transforming my images using a protective transformation matrix. I get my transformation by doing the following, where a are 4 fixed points, and b are 4 moving points.

my_tform    = fitgeotrans(a,b,'projective');

I then transform my images using imwarp and my transformation matrix my_tform as follows:

newImage = imwarp(Im,my_tform,'cubic','OutputView', imref2d( size(Im) ));

This works really well. The problem I have is that I want to know the new pixel location given a pixel location before the transformation. I need some fast code, since I would be doing this for each pixel in the image. Basically, given a location such as (256,256) in the original image, what is the new location in the transformed image?

Please see the following example image below. On the right is the original image, and on the left is the transformed image. The data tip is the same pixel in both images, but at different locations. I want to know how I can go between the two. Before and after transformation

keyserSoze
  • 137
  • 1
  • 9
  • have you read this? https://nl.mathworks.com/help/images/ref/projective2d.html So you have `my_tform`, it contains a property `my_tform.T`, and this is used to transform the points according to `[x,y 1] = [u,v,1]*T` – Gelliant Jun 28 '18 at 15:24
  • Thank you for this information. This is what I have just been trying with no luck. If I take the centre of the checker board for example, and I try to use that equation, it does not correspond to the same pixel in the transformed image. So, yes you're right - that is the theory, but I can't get it working. – keyserSoze Jun 28 '18 at 18:31
  • @keyserSoze Please post the code that you're using to transform the coordinates. We can't tell what you're doing wrong until you show us what you're doing. – beaker Jun 28 '18 at 20:36

0 Answers0