예제 #1
0
        private void CannyEdgeDetecting()
        {
            Bitmap afterGrey;
            //if (isFirstStart)
            //{
            var bmp = new Bitmap(uploadedImage);

            panel1.Invoke(new Action(() => AddImageOnPanel(new Bitmap(bmp), "Исходное изображение")));

            afterGrey = ImageProcessing.ImageToGrey(bmp);
            panel1.Invoke(new Action(() => AddImageOnPanel(new Bitmap(afterGrey), "Оттенки серого")));
            //pictureBox9.Invoke(new Action(() => pictureBox9.Image = new Bitmap(afterGrey)));
            //isFirstStart = false;
            //}
            //else
            // afterGrey = new Bitmap(pictureBox2.Image);

            //ShowSelectedImage();

            Bitmap afterGauss;

            if (checkBox2.Checked)
            {
                double sigma = 0;
                if (radioButton6.Checked)
                {
                    sigma = (double)numericUpDown4.Value;
                }
                afterGauss = Filters.GaussianFilter(afterGrey, sigma);
                panel1.Invoke(new Action(() => AddImageOnPanel(new Bitmap(afterGauss), "Фильтр Гаусса")));
            }
            else
            {
                afterGauss = afterGrey;
            }

            //ShowSelectedImage();

            Bitmap afterSobel = Edges.SobelConvolve(afterGauss);

            //Bitmap afterSobel2 = Edges.Sobel(afterGauss);
            panel1.Invoke(new Action(() => AddImageOnPanel(new Bitmap(afterSobel), "Фильтр Собеля")));
            //pictureBox14.Invoke(new Action(() => pictureBox14.Image = new Bitmap(afterSobel2)));
            //ShowSelectedImage();

            Bitmap afterSuppression = Edges.NonMaximumSuppression(afterSobel);

            //Bitmap afterSuppression2 = Edges.NonMaximumSuppression(afterSobel2);
            panel1.Invoke(new Action(() => AddImageOnPanel(new Bitmap(afterSuppression), "Подавление не-максимумов")));
            //pictureBox15.Invoke(new Action(() => pictureBox15.Image = new Bitmap(afterSuppression2)));

            //ShowSelectedImage();

            Bitmap afterThreshold = Edges.DoubleThreshold(afterSuppression, trackBar3.Value, trackBar2.Value);

            //Bitmap afterThreshold2 = Edges.DoubleThreshold(afterSuppression2, trackBar3.Value, trackBar2.Value);
            panel1.Invoke(new Action(() => AddImageOnPanel(new Bitmap(afterThreshold), "Двойная проговая фильтрация")));
            //pictureBox16.Invoke(new Action(() => pictureBox16.Image = new Bitmap(afterThreshold2)));
            //ShowSelectedImage();

            Bitmap afterEdgeTrack = Edges.EdgeTracking(afterThreshold);

            //Bitmap afterEdgeTrack2 = Edges.EdgeTracking(afterThreshold2);
            panel1.Invoke(new Action(() => AddImageOnPanel(new Bitmap(afterEdgeTrack), "Трассировка области неоднозначности")));
            //pictureBox17.Invoke(new Action(() => pictureBox17.Image = new Bitmap(afterEdgeTrack2)));
            //ShowSelectedImage();

            //Bitmap afterRestoration = Edges.BorderRestoration(afterEdgeTrack, trackBar4.Value);
            //panel1.Invoke(new Action(() => AddImageOnPanel(new Bitmap(afterRestoration), "Восстановление границ")));

            //ShowSelectedImage();
            //button1.Enabled = button6.Enabled = groupBox1.Enabled = true;
        }