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 Center および File ExchangeComputer Vision with Simulink についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by