彩色图像的分割处理程序设计+Hough算法(18)_毕业论文

毕业论文移动版

毕业论文 > 计算机论文 >

彩色图像的分割处理程序设计+Hough算法(18)


            {
                cp.Entries[i] = Color.FromArgb(i, i, i);
            }
            houghImage.Palette = cp;

            Rectangle rectHough = new Rectangle(0, 0, 180, 180);
            System.Drawing.Imaging.BitmapData houghData = houghImage.LockBits(rectHough,
            System.Drawing.Imaging.ImageLockMode.ReadWrite, houghImage.PixelFormat);
            IntPtr ptr = houghData.Scan0;
            int bytes = 180 * 180;
            byte[] grayHough = new byte[bytes];

            for (int i = 0; i < 180; i++)
            {
                for (int j = 0; j < 180; j++)
                {
                    grayHough[i * 180 + j] = Convert.ToByte(houghMap[i, j] * 255 /
                    maxHough);
                }
            }
            System.Runtime.InteropServices.Marshal.Copy(grayHough, 0, ptr, bytes);
            houghImage.UnlockBits(houghData);

            Graphics g = e.Graphics;
            g.DrawImage(houghImage, 40, 20, 180, 180);

            g.FillRectangle(Brushes.Black, 250, 20, 180, 180);

            double thresholding = maxHough * 0.6;
            double k, b;
            int x1, x2, y1, y2;
            
            for (int i = 0; i < 180; i++)
            {
                for (int j = 0; j < 180; j++)
                {
                    if (houghMap[i, j] > thresholding)
                    {
                        if (i == 90)
                        {
                            g.DrawLine(Pens.White, 250, 200, 250, 20); (责任编辑:qin)