机器视觉径向畸变校正分步实现(标定,五,径向畸变作用图像)

分两步走:

1,径向畸变作用图像

a:初心版本//20160810

           double 粗糙切向参数 = x上得到的1+k*r*r
            double 粗糙切向参数1 = y上得到的1+k*r*r
            double pingjun = (粗糙切向参数 + 粗糙切向参数1) / 2;
            byte[] buffer24 = new byte[1024 * 768 * 3];
            for (int j = 0; j < CA_H; j++)//标定图像的高
            {
                for (int i = 0; i < CA_W; i = i + 1)//标定图像的宽         
                {
                    int xcorrect = 0, ycorrect = 0;
                    xcorrect = cx + (int)((i - cx) / pingjun);//cx,cy是图像中心
                    ycorrect = cy + (int)((j - cy) / pingjun);
                    
                    buffer24[ycorrect * 1024 * 3 + xcorrect * 3] = CA_tempImage33gaos[j * CA_W  + i ];
                    buffer24[ycorrect * 1024 * 3 + xcorrect * 3 + 1] = CA_tempImage33gaos[j * CA_W  + i ];
                    buffer24[ycorrect * 1024 * 3 + xcorrect * 3 + 2] = CA_tempImage33gaos[j * CA_W + i];
                }
            }

b进化版本(最小二乘结果):

            double 切向参数 = 最小二乘x上得到的k
            double 切向参数1 =最小二乘 y上得到的k
            double pingjun = (切向参数 + 切向参数1) / 2;

             int CA_W = pictureBoxCali.Image.Width;
            int CA_H = pictureBoxCali.Image.Height;
            int cx = CA_W / 2;
            int cy = CA_H / 2;
            byte[] buffer24 = new byte[CA_W * CA_H * 3];
            for (int j = 0; j < CA_H; j++)
            {
                for (int i = 0; i < CA_W; i = i + 1)
                {
                    int xcorrect = 0, ycorrect = 0;
                    int r2 = (i - cx) * (i - cx) + (j - cy) * (j - cy);//r2是半径r*r
                    xcorrect = cx + (int)((i - cx) / (1 + pingjun * r2));//cx,cy是图像中心
                    ycorrect = cy + (int)((j - cy) / (1 + pingjun * r2));

                //标定完成后的图像byte[]201709240744
                    buffer24[ycorrect * CA_W * 3 + xcorrect * 3] = tongyongimg33gaos[j * CA_W + i];
                    buffer24[ycorrect * CA_W * 3 + xcorrect * 3 + 1] = tongyongimg33gaos[j * CA_W + i];
                    buffer24[ycorrect * CA_W * 3 + xcorrect * 3 + 2] = tongyongimg33gaos[j * CA_W + i];
                }
            }

2,显示图像

  int bytes = CA_H * CA_W * 3;

         //   Bitmap cutPic24 = new Bitmap(1024, 768, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

    Bitmap cutPic24 = new Bitmap(CA_W , CA_H , System.Drawing.Imaging.PixelFormat.Format24bppRgb);

          //  BitmapData _cutPic = cutPic24.LockBits(new Rectangle(0, 0, 1024, 768), ImageLockMode.ReadWrite,
                         //                        cutPic24.PixelFormat);

BitmapData _cutPic = cutPic24.LockBits(new Rectangle(0, 0, CA_W , CA_H ), ImageLockMode.ReadWrite,
                                               cutPic24.PixelFormat);
            IntPtr ptr = _cutPic.Scan0;//得到首地址                   
            //把cutvalues数组给ptr
            System.Runtime.InteropServices.Marshal.Copy(buffer24, 0, ptr, bytes);
            cutPic24.UnlockBits(_cutPic);

            pictureBox1.Image = cutPic24;

标定之细作脉络基本完成,有什么收获期望?

1,把线图像工具可以进化为标定板未畸变网格

2,步骤太多,应合并,或删减。

3,两种大数据,应勤加观察,亚像素角点在九宫格区域上的分布情况(径向畸变参数在九宫格区域上的分布情况)。

4,ccd中心,镜头中心,图像中心,标定板未畸变网格中心种种关系详细查看。

5,13*17行列怎么变成12*16行列的

6,不必要的算法去除,提高速度。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值