分两步走:
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,不必要的算法去除,提高速度。