예제 #1
0
 public void SuperPixelImage()
 {
     Task.Factory.StartNew(() =>
     {
         ClearPerfomanceInfo();
         RaisePropertyChanged("PerfomanceInfo");
         CanNewExecute = false;
         try
         {
             var input = OriginImage.Bitmap;
             int[] klabels;
             int numlabels;
             var superPixel = new SLICO().PerformSLICO_ForGivenK(
                 ref input,
                 out klabels,
                 out numlabels,
                 N,
                 Color.Red,
                 20);
             SegmentedImage = new ImageViewModel(superPixel);
         }
         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;
         }
     });
 }