imdist.m
上传用户:kellyonhid
上传日期:2013-10-12
资源大小:932k
文件大小:1k
源码类别:

3D图形编程

开发平台:

Visual C++

  1. function dp=imdist(name,par,p)
  2. %IMDIST distorts image coordinates with radial and tangential error
  3. %components.
  4. %
  5. %Usage:
  6. %   dp=imdist(name,par,p)
  7. %
  8. %where
  9. %   name = string that is specific to the camera and the framegrabber.
  10. %          This string must be defined in configc.m
  11. %   par  = camera intrinsic parameters
  12. %   p    = image coordinates (in pixels) to be distorted (n x 2 matrix)
  13. %   dp   = distorted image coordinates
  14. %   Version 2.0  15.5.-97
  15. %   Janne Heikkila, University of Oulu, Finland
  16. sys=configc(name);
  17. NDX=sys(1); NDY=sys(2); Sx=sys(3); Sy=sys(4);
  18. Asp=par(1); Foc=par(2);
  19. Cpx=par(3); Cpy=par(4);
  20. Rad1=par(5); Rad2=par(6);
  21. Tan1=par(7); Tan2=par(8);
  22. cx=(p(:,1)-Cpx)*Sx/NDX/Asp;
  23. cy=(p(:,2)-Cpy)*Sy/NDY;
  24. r2=cx.*cx+cy.*cy;
  25. delta=Rad1*r2+Rad2*r2.*r2;
  26. dx=cx.*(1+delta)+2*Tan1*cx.*cy+Tan2*(r2+2*cx.*cx); 
  27. dy=cy.*(1+delta)+Tan1*(r2+2*cy.*cy)+2*Tan2*cx.*cy; 
  28. dp=NDX*Asp*dx/Sx+Cpx;
  29. dp(:,2)=NDY*dy/Sy+Cpy;