%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%% 作者:WWC %%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 功能:畸变矫正 clc; clear; close all; %% 读取图像 A=imread('D:文件及下载相关图片distortion2.jpg'); [m,n,k]=size(A); R=n/2; w=3*R; h=3*R; xo=m/2; yo=n/2; f=2*R/pi; for u=1:w for v=1:h ho=sqrt((u-xo)^2+(v-yo)^2)+1; h1=f*atan2(ho,f); x=h1*(u-xo)/ho+xo; y=h1*(v-yo)/ho+yo; x=round(x); y=round(y); if(x>2*R || y>2*R || x<1 || y<1) continue; end C(u,v,1)=A(x,y,1); C(u,v,2)=A(x,y,2); C(u,v,3)=A(x,y,3); end end C=uint8(C); imshow(C);
鱼眼镜头畸变校正。(直接处理彩色图)
代码存在错误:貌似只能处理宽比长大的,竖着的。和方的。