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
 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. 3
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. 4
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. 5
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. 6
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));
                    }
                }));
            });
        }