imwarp function gives strange result
显示 更早的评论
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
2022-4-7
0 个投票
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
2022-4-7
Image Analyst
2022-4-8
I haven't used imwarp much so I can't really help on that.
类别
在 帮助中心 和 File Exchange 中查找有关 Read, Write, and Modify Image 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!