桶形/枕形失真的公式

发布于 2024-11-10 17:03:58 字数 49 浏览 3 评论 0 原文

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

Can't understand how to get (x', y') of original (x, y) in image, for Barrel/Pincushion distortion.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

聆听风音 2024-11-17 17:03:58

本文的第 2 节解释了这种转换。基本上:

在此处输入图像描述

这里我在 Mathematica:

在此处输入图像描述

Section 2 of this paper explains the transformation. Basically:

enter image description here

Here I made an example in Mathematica:

enter image description here

攒一口袋星星 2024-11-17 17:03:58

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

simple barrel\pincushion distortion in 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;
}

more complicated form
http://opencv.willowgarage.com/documentation/camera_calibration_and_3d_reconstruction.html

枕头说它不想醒 2024-11-17 17:03:58

您可以在 Fitzgibbon, 2001 中找到多项式径向畸变模型的近似值:

< img src="https://i.sstatic.net/ybNQH.png" alt="在此处输入图像描述">

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

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

我还发布了一些论文,如果你想了解数学原理,你应该看看我发布了Zhang Z. (1999) 的方法的详细信息

  • 。通过从未知方向观察平面来进行灵活的相机校准
  • Andrew W. Fitzgibbon (2001)。多视图几何和镜头畸变的同时线性估计

An approximation of the polynomial radial distortion model you can find in Fitzgibbon, 2001 is

enter image description here

where rd and ru are the distances from the center of distortion. This is also used to filter the distortion out of a wide-angle camera image for computer vision and image processing purposes.

You can find a more detailed explanation of the principle and the shader code to implement the undistortion filtering (and also the forward transformation) here: http://marcodiiga.github.io/radial-lens-undistortion-filtering

I'm also posting the papers you should take a look at if you want to know the mathematical details for the method I posted

  • Zhang Z. (1999). Flexible camera calibration by viewing a plane from unknown orientation
  • Andrew W. Fitzgibbon (2001). Simultaneous linear estimation of multiple view geometry and lens distortion
别把无礼当个性 2024-11-17 17:03:58

根据维基百科,也可以有 r 的 4 次方项。两个常数(对于第 2 项的 r 和对于第 4 项的 r)的符号可以相反,从而产生车把畸变,其中图像中心具有桶形畸变,而边缘具有枕形畸变,从而使直线呈现车把胡须的外观。

According to Wikipedia, there can also be an r to the power 4 term too. The signs of the two constants (for the r to the 2 and r to the 4 terms) can be opposite giving handlebar distortion where the centre of the image has barrel distortion and the edge has pincushion distortion giving straight lines the appearance of a handlebar moustache.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文