示例#1
0
        public void GaussianImage()
        {
            Task task = Task.Factory.StartNew(() =>
            {
                ClearPerfomanceInfo();
                RaisePropertyChanged("PerfomanceInfo");
                CanNewExecute = false;
                try
                {
                    GaussianFilter filter = new GaussianFilter();
                    RGB[,] pixels         = ImageHelper.GetPixels(OriginImage.Bitmap);
                    if (pixels != null)
                    {
                        filter.Filter(OriginImage.Bitmap.Width, OriginImage.Bitmap.Height, pixels, Sigma);

                        SegmentedImage = new ImageViewModel(ImageHelper.GetFilterBitmap(pixels));
                    }
                }
                catch { }
                finally
                {
                    CanNewExecute = true;
                }
            });
        }
示例#2
0
 public void SegmentImage()
 {
     Task task = Task.Factory.StartNew(() =>
     {
         CanNewExecute = false;
         try
         {
             IFhSegmentation segmentation = SegmentationFactory.Instance.GetFhSegmentation(SortModification, MargeHeuristic);
             RGB[,] pixels = ImageHelper.GetPixels(OriginImage.Bitmap);
             if (pixels != null)
             {
                 var input = OriginImage.Bitmap;
                 int[] klabels;
                 int numlabels;
                 var watch      = Stopwatch.StartNew();
                 var superPixel = new SLICO().PerformSLICO_ForGivenK(
                     ref input,
                     out klabels,
                     out numlabels,
                     N,
                     Color.Red);
                 watch.Stop();
                 perfomanceInfo.SuperpixelPerfomance = watch.ElapsedMilliseconds;
                 BitmapData bitmapData = superPixel.LockBits(new Rectangle(0, 0, superPixel.Width, superPixel.Height), ImageLockMode.ReadOnly, superPixel.PixelFormat);
                 var superpixels       = ImageHelper.ToMatrix(klabels, bitmapData.Width, bitmapData.Height,
                                                              bitmapData.Stride);
                 GaussianFilter filter = new GaussianFilter();
                 filter.Filter(OriginImage.Bitmap.Width, OriginImage.Bitmap.Height, pixels, Sigma);
                 int[,] segments = segmentation.BuildSegments(OriginImage.Bitmap.Width, OriginImage.Bitmap.Height, pixels, K, MinSize, Connection, DifType, ref perfomanceInfo, superpixels);
                 if (RandomColor)
                 {
                     SegmentedImage = new ImageViewModel(ImageHelper.GetBitmap(segments));
                 }
                 else
                 {
                     SegmentedImage = new ImageViewModel(ImageHelper.GetBitmap(segments, pixels, MakeBorders));
                 }
                 RaisePropertyChanged("PerfomanceInfo");
             }
         }
         catch { }
         finally
         {
             CanNewExecute = true;
         }
     });
 }