# Find coordinates of point on original image after using interp2

6 views (last 30 days)
Galo Apolo Aroca on 21 Jan 2023
Edited: Galo Apolo Aroca on 22 Jan 2023
Hello,
So I have a matrix A (10x10) of integers. I use interp2 in order to interpolate A into B, which is another matrix of 9x8.
The code I'm using is:
A=round(rand(10).*10);
[x_a,y_a] = meshgrid (linspace(1,10,8),linspace(1,10,9));
B = interp2 (A,x_a,y_a,'linear');
Is there any method to locate the coordinates of a point of matrix A within matrix B?
I am asking this because I have an image (A) which then I apply some geometric transformations (with some additions, substraction, multiplication, not with imwarp or any MATLAB builtin function) to obtain B. On the original image A I know the coordinates of a specific point, therefore I would like to know the best approximation of that point on image B.
Any help would be appreciated. Thank you

KSSV on 21 Jan 2023
Edited: KSSV on 21 Jan 2023
A=round(rand(10).*10);
[nx,ny] = size(A) ;
[X,Y] = meshgrid(1:ny,1:nx) ;
[x_a,y_a] = meshgrid (linspace(1,10,8),linspace(1,10,9));
B = interp2 (X,Y,A,x_a,y_a,'linear');
Galo Apolo Aroca on 21 Jan 2023
1) Could you explain what is this extra step in your code for?:
[nx,ny] = size(A) ;
[X,Y] = meshgrid(1:ny,1:nx) ;
2) But this doesn't answer my question. Let's say I pick the point P with coordinates (8,3) on my image A. I want to know where would that point be in output image B after interp2. Is there a method to calculate this?

### Categories

Find more on Interpolation in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by