Exemple #1
0
        //Sobel edge detection
        private void button6_Click(object sender, EventArgs e)
        {
            string strtxt = textBox1.Text;
            int    th     = Int32.Parse(strtxt);

            SobelEdgeDetection SobelEdgeDetection = new SobelEdgeDetection();

            int[,,] GX = SobelEdgeDetection.CalGX(RGBData[RGBData.Count - 1]);
            int[,,] GY = SobelEdgeDetection.CalGY(RGBData[RGBData.Count - 1]);

            newRGB   = SobelEdgeDetection.Sobel(RGBData[RGBData.Count - 1], th, GX);
            newImage = RGB2Image(newRGB);
            ImageForm MyImageA = new ImageForm(newImage, "Vertical (Sobel edge detection)"); // 建立秀圖物件

            MyImageA.Show();                                                                 // 顯示秀圖照片

            newRGB   = SobelEdgeDetection.Sobel(RGBData[RGBData.Count - 1], th, GY);
            newImage = RGB2Image(newRGB);
            ImageForm MyImageB = new ImageForm(newImage, "Horizontal (Sobel edge detection)"); // 建立秀圖物件

            MyImageB.Show();                                                                   // 顯示秀圖照片

            newRGB   = SobelEdgeDetection.Sobel(RGBData[RGBData.Count - 1], th, GX, GY);
            newImage = RGB2Image(newRGB);
            RGBData.Add(newRGB);
            ImageForm MyImageC = new ImageForm(newImage, "Combine (Sobel edge detection)"); // 建立秀圖物件

            MyImageC.Show();                                                                // 顯示秀圖照片
        }
Exemple #2
0
        public int[,,] CalOverlap(int[,,] data, int door)
        {
            SobelEdgeDetection SobelEdgeDetection = new SobelEdgeDetection();

            int[,,] GX     = SobelEdgeDetection.CalGX(data);
            int[,,] GY     = SobelEdgeDetection.CalGY(data);
            int[,,] result = SobelEdgeDetection.Sobel(data, door, GX, GY);

            for (int i = 0; i < result.GetLength(1); i++)
            {
                for (int j = 0; j < result.GetLength(2); j++)
                {
                    //是白色
                    if (result[0, i, j] == 255)
                    {
                        result[0, i, j] = 0;
                        result[1, i, j] = 255;
                        result[2, i, j] = 0;
                    }
                }
            }

            return(result);
        }