imwarp function gives strange result

조회 수: 9 (최근 30일)
Dmitriy Churin
Dmitriy Churin 2022년 4월 7일
댓글: Image Analyst 2022년 4월 8일
Hello,
I am using imwarp function to remove the lens distortion but it does not work as expected. I create displacement matrix for x and y coordinate. The displacement is nonlinear, for example dx=A*x^2. Let say my border pixel at x=3504 should go to pixel value 3204 (dx(3504)=300) after using imwarp, but it actually goes to value to a value 3246. When I use linear displacement dx=300, then everything maps correctly. Any idea how to get it done correctly?
Im=imread('car2.jpg');
[ny nx nz]=size(Im);
x=1:1:nx;
y=1:1:ny;
D_lin=zeros(ny,nx,2);
D_nonlin=zeros(ny,nx,2);
[X Y]=meshgrid(x,y);
dx_lin=300*ones(ny,nx);
dy_lin=0*ones(ny,nx);
dx_nonlin=dx_lin.*(X./nx).^2;
dy_nonlin=0;
D_lin(:,:,1)=dx_lin;
D_lin(:,:,2)=dy_lin;
D_nonlin(:,:,1)=dx_nonlin;
D_nonlin(:,:,2)=dy_nonlin;
Im_lin=imwarp(Im,D_lin);
Im_nonlin=imwarp(Im,D_nonlin);
Thanks,
Dmitriy

답변 (1개)

Image Analyst
Image Analyst 2022년 4월 7일
If you have the Computer Vision Toolbox, type "Fisheye calibration basics" into the help's search field.
The optical aberration (more accurately) called "Distortion" is also called by the layman's terms "Fisheye distortion" or "Pincushion distortion". It's where the distorted point is moved away from the optical axis by a delta that is proportional to the cube of the distance from the optic axis. Like rDistorted = rIdeal + factor * rIdeal^3. If factor is positive the point is moved away and you get pincushion distortion. If the factor is negative the point is moved closer and you have fisheye distortion.
  댓글 수: 2
Dmitriy Churin
Dmitriy Churin 2022년 4월 7일
I tried this function, but when I don't have radial symmetry it's not easy to use. So I thought it would be easier to use distortion grid from Zemax. But as I mentioned above, it's not doing what I want. Is there any other way to avoid this issue?
Image Analyst
Image Analyst 2022년 4월 8일
I haven't used imwarp much so I can't really help on that.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by