How can I transform the image to another coordinate system?

Now I want to transform an image to another coordinate. For original image, the pixel is defined as (u, v), and transformed image's pixel (u',v') can be calculated using the following equation. u'=f(L1*u+L3*f)/(-L3*u+L1*f); v'=f*v/(-L3*u+L1*f); L1,L3,f are the parameters which values is known.
After the transform, the image (left) should become like right image. I have no idea how to do this? Should I calculate the pixel values u' and v' and use the interp2? I tried but didn't work out. Please give me some advices. Thank you.

 Risposta accettata

5 Commenti

Thanks for answering my question. I have seen this and tried to write code. But there is a problem. when I write r = @(x) r1(x)./r2(x); w = @(x) f ./ r2(x); which follows the equation, there is a warning : FINDBOUNDS: Search procedure failed; returning OUTBOUNDS = INBOUNDS. I am not sure why, could you help me?
L1=0.5; L3=-0.866; f=60;
% u'= f(L1*u+L3*f)/(-L3*u+L1*f);
% v'=f*v/(-L3*u+L1*f);
r1 = @(x) L1*x(:,1) -L3*f;
r2 = @(x) L1*f - L3*x(:,1);
r = @(x) r1(x)./r2(x);
w1 = @(x) f * x(:,2);
w = @(x) f ./ r2(x);
g = @(x) [r(x), w(x)];
f = @(x, unused) g(x);
% code
end
Sorry, I don't know why either. Copying and pasting and running that code produced no error at all for me.
I see. Are you using windows system? And is the result similar to the above images?
Yes, I'm using Windows 10. Your code above doesn't do anything with images. It just defines some anonymous functions.
Sorry I forgot the rest part, the rest part is the same with the code from your link. Thank you for answering my question. I am using IOS, maybe it is the reason why error occurs. I will find a windows system computer to try it.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Convert Image Type in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by