【问题标题】:Formulas for Barrel/Pincushion distortion桶形/枕形失真的公式
【发布时间】:2011-06-01 10:21:15
【问题描述】:

对于桶形/枕形失真,无法理解如何获取图像中原始 (x, y) 的 (x', y')。

【问题讨论】:

    标签: image-processing distortion


    【解决方案1】:

    this paper 的第 2 节解释了转换。基本上:

    这里我在Mathematica做了一个例子:

    【讨论】:

    • 当在 openGL 中重新创建此代码而不进行修剪时(就像您在第 2 张图片中所做的那样),图像看起来不连贯。我使用这个算法取得了更大的成功geeks3d.com/20140213/…
    • 您的变换仅适用于将直线图像转换为失真图像,要反转该失真,您需要逆函数 p1 = cbrt(2 / (3 * a)); p2 = cbrt( sqrt(3*a) * sqrt( 27*a*x*x + 4 ) - 9*a*x ); p3 = cbrt(2) * pow(3*a, 2/3); return p1/p2 - p2/p3;
    【解决方案2】:

    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

    【讨论】:

      【解决方案3】:

      您可以在Fitzgibbon, 2001 中找到的多项式径向失真模型的近似值是

      其中 rd 和 ru 是距畸变中心的距离。这也用于过滤广角相机图像中的失真,以用于计算机视觉和图像处理。

      你可以在这里找到更详细的原理和着色器代码来实现无失真过滤(以及前向变换):http://marcodiiga.github.io/radial-lens-undistortion-filtering

      如果您想了解我发布的方法的数学细节,我还将发布您应该查看的论文

      • 张志. (1999).通过从未知方向查看平面进行灵活的相机校准
      • 安德鲁·W·菲茨吉本 (2001)。多视角几何和镜头畸变的同时线性估计

      【讨论】:

        【解决方案4】:

        根据 Wikipedia,也可以有 r 的幂 4 术语。两个常数的符号(对于 r 到 2 和 r 到 4 项)可能是相反的,从而产生车把失真,其中图像的中心具有桶形失真并且边缘具有枕形失真,从而使直线看起来像车把胡须.

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2011-06-26
          • 1970-01-01
          • 2014-09-29
          • 1970-01-01
          • 1970-01-01
          • 2015-02-25
          • 1970-01-01
          相关资源
          最近更新 更多