Пример #1
0
 public void SegmentImage()
 {
     Task task = Task.Factory.StartNew(() =>
     {
         App.Current.Dispatcher.Invoke(new Action(() =>
         {
             ProcessRunning = true;
         }));
         try
         {
             IFhSegmentation segmentation = SegmentationFactory.Instance.GetFhSegmentation();
             byte[,] pixels = ImageHelper.GetPixels(OriginImage.Bitmap);
             if (pixels != null)
             {
                 GaussianFilter filter = new GaussianFilter();
                 filter.Filter(OriginImage.Bitmap.Width, OriginImage.Bitmap.Height, pixels, 0.8);
                 int[,] segments = segmentation.BuildSegments(OriginImage.Bitmap.Width, OriginImage.Bitmap.Height, pixels, 300);
                 App.Current.Dispatcher.Invoke(new Action(() =>
                 {
                     SegmentedImage = new ImageViewModel(ImageHelper.GetBitmap(segments));
                 }));
             }
         }
         catch { }
         finally
         {
             App.Current.Dispatcher.Invoke(new Action(() =>
             {
                 ProcessRunning = false;
             }));
         }
     });
 }
Пример #2
0
 public void GaussianImage()
 {
     Task task = Task.Factory.StartNew(() =>
     {
         App.Current.Dispatcher.Invoke(new Action(() =>
         {
             ProcessRunning = true;
         }));
         try
         {
             GaussianFilter filter = new GaussianFilter();
             byte[,] pixels = ImageHelper.GetPixels(OriginImage.Bitmap);
             if (pixels != null)
             {
                 filter.Filter(OriginImage.Bitmap.Width, OriginImage.Bitmap.Height, pixels, 0.8);
                 App.Current.Dispatcher.Invoke(new Action(() =>
                 {
                     SegmentedImage = new ImageViewModel(ImageHelper.GetFilterBitmap(pixels));
                 }));
             }
         }
         catch { }
         finally
         {
             App.Current.Dispatcher.Invoke(new Action(() =>
             {
                 ProcessRunning = false;
             }));
         }
     });
 }