Image coordinate correction in MATLAB

Asked

Viewed 119 times

1

Imagem de entradaGood morning, I’m a beginner in the use of MATLAB and I believe you’re having problems with simple questions but a little help would be a great contribution.

I’m trying to perform coordinate correction on a 2048x2048 image.

As I want the center of my image to be located at the origin of the axes 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 gone over the math more than once but when applying the correction I’m getting the inverse result of the expected, the edges stretch when they should be compressed, someone would have some idea where I’m going wrong?

Thank you!

  • In a quick view of the code, I did not find anything abnormal. You would have to put the image to do an output test?

  • yes @guto, no problem.

  • Thanks, as soon as I get some time I’ll take a look :D !

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.