Beispiel #1
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);
     }
 }
Beispiel #2
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);
        }
Beispiel #3
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;
                }
            }
        }