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!