{
rgbValues[i * 3 + 2] = Convert.ToByte(kAver[j * 3 + 2]);
rgbValues[i * 3 + 1] = Convert.ToByte(kAver[j * 3 + 1]);
rgbValues[i * 3] = Convert.ToByte(kAver[j * 3]);
}
}
}
System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes * 3);
curBitmap.UnlockBits(bmpData);
Invalidate();
}
}
}
4.2.2 Hough变换
图4.4 Hough变换原图
图4.5 Hough变换原图
左边是经过灰度拉伸后的Hough变换映射图像,两条最亮的弧线是由一个个点组成,每个点代表原图中的一条直线。
右边为根据左边图像进行Hough反变换后得到的图像。通过与原图相比,这些直线不仅能检测出来,而且位置也准确无误。
以下为Hough变换处理代码:
private void hough_Click_1(object sender, EventArgs e)
{
if (curBitmap != null)
{
hough houghtran = new hough(curBitmap);
houghtran.ShowDialog();
}
}
private void close_Click(object sender, EventArgs e)
{
this.Close();
}
private void hough_Paint(object sender, PaintEventArgs e)
{
Bitmap houghImage = new Bitmap(180, 180,
System.Drawing.Imaging.PixelFormat.Format8bppIndexed);
System.Drawing.Imaging.ColorPalette cp = houghImage.Palette;
for (int i = 0; i < 256; i++) 彩色图像的分割处理程序设计+Hough算法(17):http://www.youerw.com/jisuanji/lunwen_1067.html