Exemple #1
0
        public Bitmap CannyProcessing(SmoothMatrixType type, int size)
        {
            Invoke(new Action(() => StateLbl.Text = "Начато преобразование"));
            var bitmap = new Bitmap(originalPic, 64, 64).GetBWPicture();

            Invoke(new Action(() =>
            {
                StateLbl.Text      = "Получено чернобелое изображение";
                resultPicBox.Image = bitmap;
                UpdateForm();
            }));

            var smoothedBWPicture = bitmap.SmoothBWPicture(type, size);

            Invoke(new Action(() =>
            {
                StateLbl.Text = "Получено размытое изображение";
                resultPic     = bitmap;
                UpdateForm();
            }));

            var gradients = smoothedBWPicture.FindGradients();

            Invoke(new Action(() =>
            {
                StateLbl.Text = "Найдены градиенты";
                StateLbl.Refresh();
            }));

            var gradientsWithSuppressedMaximums = gradients.SuppressMaximums();

            Invoke(new Action(() =>
            {
                StateLbl.Text = "Удалены немаксимумы";
                StateLbl.Refresh();
            }));

            var cuttedGradients = gradientsWithSuppressedMaximums.BlackEdge(size / 2 + 1);

            Invoke(new Action(() =>
            {
                StateLbl.Text = "Закрашены края";
                StateLbl.Refresh();
            }));

            var filteredGradients = cuttedGradients;//.Filtering();

            //Invoke(new Action(() =>
            //{
            //    StateLbl.Text = "Произведена фильтрация. Готово!";
            //    StateLbl.Refresh();
            //}));

            //Invoke(new Action(() =>
            //{
            //    StateLbl.Text = "Нейросеть вычисляет есть ли человек на фотографии!";
            //    StateLbl.Refresh();
            //    BNPNet net = new BNPNet(@"C:\Users\vladb\Desktop\somaset\network.json");

            //    var output = net.GetResult(filteredGradients.LengthsToArray().ToVector());
            //    StateLbl.Text = "Человек " + ((1 - output[0]) < 0.2 ? "присутствует" : "отсутствует") + " на фотографии";
            //    StateLbl.Refresh();
            //}));

            return(filteredGradients.ToBitmap());
        }
Exemple #2
0
 public void UpdateForm()
 {
     originalPicBox.Refresh();
     resultPicBox.Refresh();
     StateLbl.Refresh();
 }