Correction of image coordinates in MATLAB

1

Good morning, I am a beginner in MATLAB and I believe you are having problems with simple questions but a little help would be a great contribution.

I'm trying to perform coordinate correction of an image of size 2048x2048.

As I want the center of my image to be located in the axis source, I used the following commands:

Ii=imread('PVCgrid.tif');
figure; imshow(Ii)


DFD = 265;
R = 205;
P = 0.2;



[L,C]=size(Ii);


[yi,xi] =  meshgrid(-(L-1)/2:(L-1)/2,-(C-1)/2:(C-1)/2);%(pixels)


[Y,X] = meshgrid(1:L,1:C);%(pixels)


yc = yi.*0.2;%(mm)
xc = xi.*0.2;%(mm)
% transforma as unidades das coordenadas de pixel para mm



a = (yc.^2) + (DFD^2)+(xc.^2);%(mm)
b = 2*(-(DFD^2)+(R*DFD));%(mm)
c = ((DFD^2) - (2*R*DFD));%(mm)


delta = b^2 - ((4.*a) * c);
denominador = 2 .* a;
numerador_1 = -(b) + sqrt(delta);
numerador_2 = -(b) - sqrt(delta);

t_1 = numerador_1 ./ denominador;

%Determina o fator de correção

u1 =(yc.*t_1);
v1 =(xc.*t_1);
% Aplica a correção

u =u1./P;
v =v1./P;
% Retorna para a unidade original


tmap_B = cat(3,u_transl,v_transl);

resamp = makeresampler('linear','fill');

Io = tformarray(Ii,[],resamp,[2 1],[1 2],[],tmap_B,1);

imwrite(Io,'gridcorrigida.tif','tif')

figure; imshow(Io)

I've done math more than once but when I apply the correction I'm having the opposite result expected, the edges stretch when they should be compressed, would anyone have any idea where I'm going wrong?

Thank you!

    
asked by anonymous 11.08.2017 / 20:19

0 answers