2011-06-01 49 views

回答

18

this paper的第2部分解釋了轉換。基本上:

enter image description here

在這裏,我在Mathematica製成一個例子:

enter image description here

+2

在openGL中重新創建此代碼時,如果沒有修整(就像您在前兩張圖片中那樣),圖像看起來會脫節。我使用這種算法取得了更大的成功http://www.geeks3d.com/20140213/glsl-shader-library-fish-eye-and-dome-and-barrel-distortion-post-processing-filters/2/ – user819640 2015-09-29 08:42:23

+0

您的變換隻適用於將直線圖像轉換爲失真圖像,爲了逆轉該失真,需要反函數p1 = cbrt(2 /(3 * a)); \t p2 = cbrt(sqrt(3 * a)* sqrt(27 * a * x * x + 4)-9 * a * x); \t p3 = cbrt(2)* pow(3 * a,2/3); \t return p1/p2-p2/p3;' – 2017-04-16 19:43:37

0

在OpenCV中C++

IplImage* barrel_pincusion_dist(IplImage* img, double Cx,double Cy,double kx,double ky) 
{ 
    IplImage* mapx = cvCreateImage(cvGetSize(img), IPL_DEPTH_32F, 1); 
    IplImage* mapy = cvCreateImage(cvGetSize(img), IPL_DEPTH_32F, 1); 

    int w= img->width; 
    int h= img->height; 

    float* pbuf = (float*)mapx->imageData; 
    for (int y = 0; y < h; y++) 
    { 
     for (int x = 0; x < w; x++) 
     {   
      float u= Cx+(x-Cx)*(1+kx*((x-Cx)*(x-Cx)+(y-Cy)*(y-Cy))); 
      *pbuf = u; 
      ++pbuf; 
     } 
    } 

    pbuf = (float*)mapy->imageData; 
    for (int y = 0;y < h; y++) 
    { 
     for (int x = 0; x < w; x++) 
     { 
      *pbuf = Cy+(y-Cy)*(1+ky*((x-Cx)*(x-Cx)+(y-Cy)*(y-Cy))); 
      ++pbuf; 
     } 
    } 

    /*float* pbuf = (float*)mapx->imageData; 
    for (int y = 0; y < h; y++) 
    { 
     int ty= y-Cy; 
     for (int x = 0; x < w; x++) 
     { 
      int tx= x-Cx; 
      int rt= tx*tx+ty*ty; 

      *pbuf = (float)(tx*(1+kx*rt)+Cx); 
      ++pbuf; 
     } 
    } 

    pbuf = (float*)mapy->imageData; 
    for (int y = 0;y < h; y++) 
    { 
     int ty= y-Cy; 
     for (int x = 0; x < w; x++) 
     { 
      int tx= x-Cx; 
      int rt= tx*tx+ty*ty; 

      *pbuf = (float)(ty*(1+ky*rt)+Cy); 
      ++pbuf; 
     } 
    }*/ 

    IplImage* temp = cvCloneImage(img); 
    cvRemap(temp, img, mapx, mapy); 
    cvReleaseImage(&temp); 
    cvReleaseImage(&mapx); 
    cvReleaseImage(&mapy); 

    return img; 
} 

更復雜的形式簡單桶\枕形失真 http://opencv.willowgarage.com/documentation/camera_calibration_and_3d_reconstruction.html

1

多項式徑向畸變模型,你可以在Fitzgibbon, 2001找到的近似

enter image description here

其中RD和RU是從失真的中心的距離。這也用於過濾廣角相機圖像中的失真,以用於計算機視覺和圖像處理目的。

您可以在這裏找到的原則更詳細的解釋,並且着色器代碼來實現undistortion過濾(也正向轉換):http://marcodiiga.github.io/radial-lens-undistortion-filtering

我還張貼的文件,你應該看看如果你想知道我發佈的方法的數學細節

  • Zhang Z.(1999)。通過從未知方向觀察飛機進行靈活的攝像機校準
  • Andrew W. Fitzgibbon(2001)。多視圖幾何和鏡頭失真的同時線性估計