Esempio n. 1
0
 public Processing(System.Windows.Controls.Image mainImage)
 {
     InitializeComponent();
     imageControl  = mainImage;
     originalImage = SourceBitmapConverter.BitmapFromSource(mainImage.Source);
     forReset      = SourceBitmapConverter.BitmapFromSource(mainImage.Source);
 }
Esempio n. 2
0
 private void GrayScale_Click(object sender, RoutedEventArgs e)
 {
     if (imageControl == null || imageControl.Source == null)
     {
         return;
     }
     imageControl.Source = SourceBitmapConverter.ImageSourceFromBitmap(CvProcessor.ToGray(originalImage));
 }
Esempio n. 3
0
 private void BinSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
 {
     changeInvoker = ChangeInvoker.Binarization;
     if (imageControl == null || imageControl.Source == null || InteractiveMode.IsChecked != true)
     {
         return;
     }
     imageControl.Source = SourceBitmapConverter.ImageSourceFromBitmap(CvProcessor.ChangeBin(originalImage, (int)BinSlider1.Value, (int)BinSlider2.Value));
 }
Esempio n. 4
0
 public void PopulateData(List <BloodObjects> objects, System.Windows.Controls.Image img, string fileName)
 {
     allObjects           = objects;
     MainGrid.ItemsSource = allObjects;
     mainImage            = img;
     this.fileName        = fileName;
     all = SourceBitmapConverter.BitmapFromSource(mainImage.Source);
     RecountSummary();
 }
Esempio n. 5
0
 private void Filter_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (Filter.SelectedItem == null || (Group)Filter.SelectedItem == Group.All)
     {
         MainGrid.ItemsSource = null;
         MainGrid.ItemsSource = allObjects;
         mainImage.Source     = SourceBitmapConverter.ImageSourceFromBitmap(all);
     }
     else
     {
         MainGrid.ItemsSource = allObjects.Where(a => a.Group == (Group)Filter.SelectedItem);
         var result = ContoursEngine.DrawObjectsOnImage(new Bitmap(fileName), allObjects.Where(a => a.Group == (Group)Filter.SelectedItem).ToList());
         mainImage.Source = SourceBitmapConverter.ImageSourceFromBitmap(result);
     }
 }
Esempio n. 6
0
 private void BrightnessSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
 {
     changeInvoker = ChangeInvoker.Brightness;
     if (imageControl == null || imageControl.Source == null || InteractiveMode.IsChecked != true)
     {
         return;
     }
     float[] kernel = new float[9];
     kernel[0]           = ((float)BrightnessSlider1.Value) / 10;
     kernel[1]           = ((float)BrightnessSlider2.Value) / 10;
     kernel[2]           = ((float)BrightnessSlider3.Value) / 10;
     kernel[3]           = ((float)BrightnessSlider4.Value) / 10;
     kernel[4]           = ((float)BrightnessSlider5.Value) / 10;
     kernel[5]           = ((float)BrightnessSlider6.Value) / 10;
     kernel[6]           = ((float)BrightnessSlider7.Value) / 10;
     kernel[7]           = ((float)BrightnessSlider8.Value) / 10;
     kernel[8]           = ((float)BrightnessSlider9.Value) / 10;
     imageControl.Source = SourceBitmapConverter.ImageSourceFromBitmap(CvProcessor.ChangeBrighness(originalImage, kernel));
 }
Esempio n. 7
0
        private void GetResult_Click(object sender, RoutedEventArgs e)
        {
            if (MainImage.Source == null)
            {
                return;
            }

            var image = SourceBitmapConverter.BitmapFromSource(MainImage.Source);

            image = CvProcessor.AdaptiveThreshold(image, 200, 101);
            Bitmap result;
            List <BloodObjects> objects = new List <BloodObjects>();

            ContoursEngine.GetAllObjects(image, out result, out objects, "");
            MainImage.Source = SourceBitmapConverter.ImageSourceFromBitmap(result);
            table.Show();
            table.Activate();
            table.PopulateData(objects, MainImage, fileName);
        }
Esempio n. 8
0
        private void Apply_Click(object sender, RoutedEventArgs e)
        {
            if (imageControl == null || imageControl.Source == null)
            {
                return;
            }
            switch (changeInvoker)
            {
            case ChangeInvoker.Smooth:
                imageControl.Source = SourceBitmapConverter.ImageSourceFromBitmap(CvProcessor.ChangeSmooth(originalImage, (int)SmoothSlider.Value));
                break;

            case ChangeInvoker.Brightness:
                float[] kernel = new float[9];
                kernel[0]           = ((float)BrightnessSlider1.Value) / 10;
                kernel[1]           = ((float)BrightnessSlider2.Value) / 10;
                kernel[2]           = ((float)BrightnessSlider3.Value) / 10;
                kernel[3]           = ((float)BrightnessSlider4.Value) / 10;
                kernel[4]           = ((float)BrightnessSlider5.Value) / 10;
                kernel[5]           = ((float)BrightnessSlider6.Value) / 10;
                kernel[6]           = ((float)BrightnessSlider7.Value) / 10;
                kernel[7]           = ((float)BrightnessSlider8.Value) / 10;
                kernel[8]           = ((float)BrightnessSlider9.Value) / 10;
                imageControl.Source = SourceBitmapConverter.ImageSourceFromBitmap(CvProcessor.ChangeBrighness(originalImage, kernel));
                break;

            case ChangeInvoker.Canny:
                imageControl.Source = SourceBitmapConverter.ImageSourceFromBitmap(CvProcessor.Canny(originalImage, (int)CannySlider1.Value, (int)CannySlider2.Value, (int)CannySlider3.Value));
                break;

            case ChangeInvoker.Threshold:
                imageControl.Source = SourceBitmapConverter.ImageSourceFromBitmap(CvProcessor.AdaptiveThreshold(originalImage, (int)AdaptiveSlider1.Value, (int)AdaptiveSlider2.Value));
                break;

            case ChangeInvoker.Binarization:
                imageControl.Source = SourceBitmapConverter.ImageSourceFromBitmap(CvProcessor.ChangeBin(originalImage, (int)BinSlider1.Value, (int)BinSlider2.Value));
                break;
            }

            originalImage = SourceBitmapConverter.BitmapFromSource(imageControl.Source);
        }
Esempio n. 9
0
 private void Reset_Click(object sender, RoutedEventArgs e)
 {
     BinSlider1.Value        = 0;
     BinSlider2.Value        = 255;
     SmoothSlider.Value      = 1;
     CannySlider1.Value      = 0;
     CannySlider2.Value      = 100;
     CannySlider3.Value      = 1;
     AdaptiveSlider1.Value   = 0;
     AdaptiveSlider2.Value   = 101;
     BrightnessSlider1.Value = 2;
     BrightnessSlider2.Value = 2;
     BrightnessSlider3.Value = 2;
     BrightnessSlider4.Value = 2;
     BrightnessSlider5.Value = 0;
     BrightnessSlider6.Value = 2;
     BrightnessSlider7.Value = 2;
     BrightnessSlider8.Value = 2;
     BrightnessSlider9.Value = 2;
     imageControl.Source     = SourceBitmapConverter.ImageSourceFromBitmap(forReset);
     originalImage           = forReset;
 }
Esempio n. 10
0
        private void MainImage_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (InteractiveMode.IsChecked != true)
            {
                return;
            }
            var coords = GetCoordsRelatedToImage(e);

            if (coords.X < 0 || coords.Y < 0)
            {
                return;
            }

            if (isEtalon)
            {
                var dialog = new InputBox();
                if (dialog.ShowDialog() == true)
                {
                    realArea = double.Parse(dialog.LeafArea);
                    Bitmap result;
                    List <ComplexObject> allItems = new List <ComplexObject>();
                    ContoursEngine.GetAllObjects(SourceBitmapConverter.BitmapFromSource(MainImage.Source), coords, out result, out etalonObject, out allItems);
                    if (OneByOne.IsChecked != true)
                    {
                        MainImage.Source = SourceBitmapConverter.ImageSourceFromBitmap(result);
                        if (allItems == null)
                        {
                            return;
                        }
                        table.PopulateData(allItems, etalonObject, realArea);
                        OneByOne.IsEnabled = false;
                        OneByOne.IsChecked = false;
                    }
                    else
                    {
                        double area = 0;
                        ContoursEngine.GetSingleContour(SourceBitmapConverter.BitmapFromSource(MainImage.Source), coords, global_id, SourceBitmapConverter.BitmapFromSource(MainImage.Source), out result, out area);
                        MainImage.Source = SourceBitmapConverter.ImageSourceFromBitmap(result);
                        global_id++;
                    }
                    isEtalon = false;
                    table.Show();
                    table.Activate();
                }
            }
            else
            {
                if (OneByOne.IsChecked == true)
                {
                    Bitmap result;
                    double area = 0;
                    ContoursEngine.GetSingleContour(SourceBitmapConverter.BitmapFromSource(MainImage.Source), coords, global_id, SourceBitmapConverter.BitmapFromSource(MainImage.Source), out result, out area);
                    MainImage.Source = SourceBitmapConverter.ImageSourceFromBitmap(result);
                    if (area != 0)
                    {
                        table.AddItem(area, realArea, etalonObject, global_id);
                        global_id++;
                    }
                    OneByOne.IsEnabled = false;
                    OneByOne.IsChecked = true;
                }
            }
        }
Esempio n. 11
0
        private void BuildRoute_Click(object sender, RoutedEventArgs e)
        {
            if (MapImage.Source == null || routeImages.Count < 2)
            {
                return;
            }

            MainTabControl.Opacity = 0.2;
            Progress.Value         = 0;
            Report.Text            = $"{0}/{routeImages.Count} images processed";
            FileMenuItem.IsEnabled = false;
            BuildRoute.IsEnabled   = false;

            new TaskFactory().StartNew(() =>
            {
                double k = 0;
                foreach (var image in routeImages)
                {
                    results.Add(RouteEngine.Run(new AirPhoto(new Bitmap(map), map), new AirPhoto(new Bitmap(image.FileName), image.FileName)));
                    k++;
                    Dispatcher.BeginInvoke(new Action(() =>
                    {
                        Progress.Value = (k / routeImages.Count) * 100;
                        Report.Text    = $"{k}/{routeImages.Count} images processed";
                    }));
                }

                Dispatcher.BeginInvoke(new Action(() =>
                {
                    FileMenuItem.IsEnabled = true;
                    BuildRoute.IsEnabled   = true;
                    MainTabControl.Opacity = 1;
                    for (int i = 0; i < results.Count; i++)
                    {
                        var bitmap = results[i].RAWmatchestoBitmap();
                        var image  = new System.Windows.Controls.Image
                        {
                            Source = SourceBitmapConverter.ImageSourceFromBitmap(bitmap)
                        };
                        var tab = new TabItem
                        {
                            Header  = Path.GetFileNameWithoutExtension(results[i].SingleImage.FileName),
                            Content = image
                        };
                        ResultsTabControl.Items.Add(tab);

                        results[i]    = RouteEngine.FilterPoints(results[i]);
                        results[i].Id = i + 1;
                        routeImages.ElementAt(i).ImageControl.Source = SourceBitmapConverter.ImageSourceFromBitmap(results[i].SingleImage.AfterClusterizationtoBitmap());
                    }
                    if (DrawingSettings.DrawKeyPoints)
                    {
                        MapImage.Source = SourceBitmapConverter.ImageSourceFromBitmap(RouteEngine.DrawKPAtMap(SourceBitmapConverter.BitmapFromSource(MapImage.Source), results));
                    }
                    if (DrawingSettings.DrawBounds)
                    {
                        MapImage.Source = SourceBitmapConverter.ImageSourceFromBitmap(RouteEngine.DrawBounds(SourceBitmapConverter.BitmapFromSource(MapImage.Source), results));
                    }
                    if (DrawingSettings.DrawRoute)
                    {
                        MapImage.Source = SourceBitmapConverter.ImageSourceFromBitmap(RouteEngine.BuildRoute(SourceBitmapConverter.BitmapFromSource(MapImage.Source), results));
                    }
                }));
            });
        }