Class GraphCutMaskingOptions

Class GraphCutMaskingOptions

Tên không gian: Aspose.Imaging.Masking.Options Tổng hợp: Aspose.Imaging.dll (25.4.0)

Các tùy chọn GraphCut Auto Masking.

public class GraphCutMaskingOptions : MaskingOptions

Inheritance

object MaskingOptions GraphCutMaskingOptions

Derived

AutoMaskingGraphCutOptions

Thành viên thừa kế

MaskingOptions.BackgroundObjectNumber , MaskingOptions.Method , MaskingOptions.Args , MaskingOptions.ExportOptions , MaskingOptions.MaskingArea , MaskingOptions.Decompose , MaskingOptions.BackgroundReplacementColor , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

Tiết kiệm kết quả mặt nạ hình ảnh với trang điểm dựa trên kích cỡ ảnh. Image masking được thực hiện bằng cách sử dụng tự động tính toán đột quỵ mặc định. Tài sản của Args của AutoMaskingGraphCutOptions có thể bị bỏ qua vì đột Quỵ giả định được đặt ở đó ở cuối.

MaskingResult[] results;
                                                                                                                                                                                                                                                               using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
                                                                                                                                                                                                                                                               {
                                                                                                                                                                                                                                                                   AutoMaskingGraphCutOptions options = new AutoMaskingGraphCutOptions
                                                                                                                                                                                                                                                                                                               {
                                                                                                                                                                                                                                                                                                                   CalculateDefaultStrokes = true,
                                                                                                                                                                                                                                                                                                                   FeatheringRadius = (Math.Max(image.Width, image.Height) / 500) + 1,
                                                                                                                                                                                                                                                                                                                   Method = SegmentationMethod.GraphCut,
                                                                                                                                                                                                                                                                                                                   Decompose = false,
                                                                                                                                                                                                                                                                                                                   ExportOptions =
                                                                                                                                                                                                                                                                                                                       new PngOptions()
                                                                                                                                                                                                                                                                                                                           {
                                                                                                                                                                                                                                                                                                                               ColorType = PngColorType.TruecolorWithAlpha,
                                                                                                                                                                                                                                                                                                                               Source = new FileCreateSource("tempFile")
                                                                                                                                                                                                                                                                                                                           },
                                                                                                                                                                                                                                                                                                                   BackgroundReplacementColor = Color.Transparent
                                                                                                                                                                                                                                                                   };

                                                                                                                                                                                                                                                                   results = new ImageMasking(image).Decompose(options);
                                                                                                                                                                                                                                                               }

                                                                                                                                                                                                                                                               using (RasterImage resultImage = (RasterImage)results[1].GetImage())
                                                                                                                                                                                                                                                               {
                                                                                                                                                                                                                                                                   resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
                                                                                                                                                                                                                                                               }

Tiết kiệm kết quả mặt nạ hình ảnh với tính toán dựa trên kích cỡ ảnh. Image masking được thực hiện bằng cách sử dụng tự động calculated default strokes. Thêm vào đó, dữ liệu của hai đối tượng giả định cũng được xác định trong AssumedObjects thuộc tính của AutoMaskingGraphCutOptions.

List<assumedobjectdata> assumedObjects = new List<assumedobjectdata>();
                                                                                                                                                                                                                                                                                  assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Human, new Rectangle(100, 100, 150, 300)));
                                                                                                                                                                                                                                                                                  assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Dog, new Rectangle(300, 100, 50, 30)));

                                                                                                                                                                                                                                                                                  MaskingResult[] results;
                                                                                                                                                                                                                                                                                  using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
                                                                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                                                                      AutoMaskingGraphCutOptions options = new AutoMaskingGraphCutOptions
                                                                                                                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                                                                                                                      AssumedObjects = assumedObjects,
                                                                                                                                                                                                                                                                                                                                      CalculateDefaultStrokes = true,
                                                                                                                                                                                                                                                                                                                                      FeatheringRadius = (Math.Max(image.Width, image.Height) / 500) + 1,
                                                                                                                                                                                                                                                                                                                                      Method = SegmentationMethod.GraphCut,
                                                                                                                                                                                                                                                                                                                                      Decompose = false,
                                                                                                                                                                                                                                                                                                                                      ExportOptions =
                                                                                                                                                                                                                                                                                                                                          new PngOptions()
                                                                                                                                                                                                                                                                                                                                              {
                                                                                                                                                                                                                                                                                                                                                  ColorType = PngColorType.TruecolorWithAlpha,
                                                                                                                                                                                                                                                                                                                                                  Source = new FileCreateSource("tempFile")
                                                                                                                                                                                                                                                                                                                                              },
                                                                                                                                                                                                                                                                                                                                      BackgroundReplacementColor = Color.Transparent
                                                                                                                                                                                                                                                                                      };

                                                                                                                                                                                                                                                                                      results = new ImageMasking(image).Decompose(options);
                                                                                                                                                                                                                                                                                  }

                                                                                                                                                                                                                                                                                  using (RasterImage resultImage = (RasterImage)results[1].GetImage())
                                                                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                                                                      resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
                                                                                                                                                                                                                                                                                  }</assumedobjectdata></assumedobjectdata>

Tiết kiệm Graph Cut image masking result with feathering set to 3. hình ảnh mask is performed using specified Point array.

MaskingResult[] results;
                                                                                                                                  using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
                                                                                                                                  {
                                                                                                                                      GraphCutMaskingOptions options = new GraphCutMaskingOptions()
                                                                                                                                                                                  {
                                                                                                                                                                                      FeatheringRadius = 3,
                                                                                                                                                                                      Method = SegmentationMethod.GraphCut,
                                                                                                                                                                                      Decompose = false,
                                                                                                                                                                                      ExportOptions =
                                                                                                                                                                                          new PngOptions()
                                                                                                                                                                                              {
                                                                                                                                                                                                  ColorType = PngColorType.TruecolorWithAlpha,
                                                                                                                                                                                                  Source = new FileCreateSource("tempFile")
                                                                                                                                                                                              },
                                                                                                                                                                                      BackgroundReplacementColor = Color.Transparent,
                                                                                                                                                                                      Args = new AutoMaskingArgs()
                                                                                                                                                                                              {
                                                                                                                                                                                                  ObjectsPoints = new Point[][]
                                                                                                                                                                                                                      {
                                                                                                                                                                                                                          new Point[]
                                                                                                                                                                                                                              {
                                                                                                                                                                                                                                  new Point(100, 100),
                                                                                                                                                                                                                              },
                                                                                                                                                                                                                      }
                                                                                                                                                                                              }
                                                                                                                                                                                  };

                                                                                                                                      results = new ImageMasking(image).Decompose(options);
                                                                                                                                  }

                                                                                                                                  using (RasterImage resultImage = (RasterImage)results[1].GetImage())
                                                                                                                                  {
                                                                                                                                      resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
                                                                                                                                  }

Tiết kiệm kết quả mặt nạ hình ảnh bằng cách nhấp chuột dựa trên kích cỡ ảnh và tái sử dụng các tùy chọn mặt Nạ cho iteration mới. Image masking được thực hiện bằng phương tiện tự động tính toán các tác động mặc định. Ngoài ra, dữ liệu của hai đối tượng được giả định cũng được xác định trong tài sản của AssumedObjects của AutoMaskingGraphCutOptions. Sau khi nhận được kết thúc đầu tiên, áp dụng background/foreground tác hại được sửa đổi và một tác phẩm khác được làm theo.

List<assumedobjectdata> assumedObjects = new List<assumedobjectdata>();
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Human, new Rectangle(100, 100, 150, 300)));
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Dog, new Rectangle(300, 100, 50, 30)));

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  MaskingResult[] results;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  AutoMaskingGraphCutOptions options;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      options = new AutoMaskingGraphCutOptions
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          AssumedObjects = assumedObjects,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          CalculateDefaultStrokes = true,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          FeatheringRadius = 3,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Method = SegmentationMethod.GraphCut,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Decompose = false,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ExportOptions =
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              new PngOptions()
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ColorType = PngColorType.TruecolorWithAlpha,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Source = new FileCreateSource("tempFile")
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  },
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          BackgroundReplacementColor = Color.Transparent
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      };

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      results = new ImageMasking(image).Decompose(options);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  }

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  // At this point applied foreground/background strokes can be analyzed and based on it additional 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  // foreground/background strokes can be manually provided.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Point[] appliedBackgroundStrokes = options.DefaultBackgroundStrokes;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Point[] appliedForegroundStrokes = options.DefaultForegroundStrokes;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Rectangle[] appliedObjectRectangles = options.DefaultObjectsRectangles;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  using (RasterImage resultImage = (RasterImage)results[1].GetImage())
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  }

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      // Re-using AutoMaskingGraphCutOptions there is no need to perform default strokes calculations second time.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      options.CalculateDefaultStrokes = false;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      // When both default strokes and ObjectsPoints in the Args property of AutoMaskingArgs are provided, Point arrays are end up combined.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      // The first ObjectsPoints array is considered to be a background points array and 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      // the second ObjectsPoints array is considered to be a foreground points array.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      // When both DefaultObjectsRectangles and ObjectsRectangles in the Args property of AutoMaskingArgs are provided, 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      // only the array from the Args is being used.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      options.Args = new AutoMaskingArgs()
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ObjectsPoints = new Point[][]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      new Point[] { new Point(100, 100), new Point(150, 100) }, 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      new Point[] { new Point(500, 200) }, 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  },
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ObjectsRectangles = new Rectangle[]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          new Rectangle(100, 100, 300, 300), 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          };
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      results = new ImageMasking(image).Decompose(options);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  }

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  using (RasterImage resultImage = (RasterImage)results[1].GetImage())
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  }</assumedobjectdata></assumedobjectdata>

Tiết kiệm kết quả mặt nạ hình ảnh dựa trên kích cỡ ảnh, sửa đổi các vết nứt mặc định được thu được và sử dụng nó cho iteration trang điểm mới. Image masking được thực hiện bằng cách tự động tính toán các cú đố giả định. Thêm vào đó, dữ liệu của hai đối tượng dự đoán cũng được chỉ định trong tài sản AssumedObjects của AutoMaskingGraphCutOptions. Sau khi nhận được kết cục đầu tiên, áp dụng background/foreground strokes được thay đổi và một lần nữa mặt Nạ Iterations được tiến hành với ứng dụng mới GraphCotMaskinOption.

List<assumedobjectdata> assumedObjects = new List<assumedobjectdata>();
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Human, new Rectangle(100, 100, 150, 300)));
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Dog, new Rectangle(300, 100, 50, 30)));

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                MaskingResult[] results;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                AutoMaskingGraphCutOptions options;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    options = new AutoMaskingGraphCutOptions
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        AssumedObjects = assumedObjects,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        CalculateDefaultStrokes = true,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        FeatheringRadius = 3,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Method = SegmentationMethod.GraphCut,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Decompose = false,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ExportOptions =
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            new PngOptions()
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ColorType = PngColorType.TruecolorWithAlpha,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Source = new FileCreateSource("tempFile")
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                },
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        BackgroundReplacementColor = Color.Transparent
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    };

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    results = new ImageMasking(image).Decompose(options);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                }

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                // At this point applied foreground/background strokes can be analyzed and based on it additional 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                // foreground/background strokes can be manually provided.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Point[] appliedBackgroundStrokes = options.DefaultBackgroundStrokes;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Point[] appliedForegroundStrokes = options.DefaultForegroundStrokes;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Rectangle[] appliedObjectRectangles = options.DefaultObjectsRectangles;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                using (RasterImage resultImage = (RasterImage)results[1].GetImage())
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                }

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                appliedBackgroundStrokes[5] = new Point(100, 100);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                appliedBackgroundStrokes[15] = new Point(150, 100);

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                appliedForegroundStrokes[1] = new Point(500, 200);

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                appliedObjectRectangles[0] = new Rectangle(100, 100, 300, 300);

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    GraphCutMaskingOptions graphCutOptions = new GraphCutMaskingOptions()
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        FeatheringRadius = 3,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Method = SegmentationMethod.GraphCut,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Decompose = false,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ExportOptions = new PngOptions()
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ColorType = PngColorType.TruecolorWithAlpha,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Source = new FileCreateSource("tempFile")
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            },
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        BackgroundReplacementColor = Color.Transparent,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Args = new AutoMaskingArgs()
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ObjectsPoints = new Point[][]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            appliedBackgroundStrokes,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            appliedForegroundStrokes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        },
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ObjectsRectangles = appliedObjectRectangles
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    };
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    results = new ImageMasking(image).Decompose(graphCutOptions);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                }

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                using (RasterImage resultImage = (RasterImage)results[1].GetImage())
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                }</assumedobjectdata></assumedobjectdata>

Constructors

GraphCutMaskingOptions()

public GraphCutMaskingOptions()

Properties

FeatheringRadius

Nhận hoặc đặt ra đường ray.

public int FeatheringRadius { get; set; }

Giá trị bất động sản

int

Examples

Tiết kiệm kết quả mặt nạ hình ảnh với trang điểm dựa trên kích cỡ ảnh. Image masking được thực hiện bằng cách sử dụng tự động tính toán đột quỵ mặc định. Tài sản của Args của AutoMaskingGraphCutOptions có thể bị bỏ qua vì đột Quỵ giả định được đặt ở đó ở cuối.

MaskingResult[] results;
                                                                                                                                                                                                                                                               using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
                                                                                                                                                                                                                                                               {
                                                                                                                                                                                                                                                                   AutoMaskingGraphCutOptions options = new AutoMaskingGraphCutOptions
                                                                                                                                                                                                                                                                                                               {
                                                                                                                                                                                                                                                                                                                   CalculateDefaultStrokes = true,
                                                                                                                                                                                                                                                                                                                   FeatheringRadius = (Math.Max(image.Width, image.Height) / 500) + 1,
                                                                                                                                                                                                                                                                                                                   Method = SegmentationMethod.GraphCut,
                                                                                                                                                                                                                                                                                                                   Decompose = false,
                                                                                                                                                                                                                                                                                                                   ExportOptions =
                                                                                                                                                                                                                                                                                                                       new PngOptions()
                                                                                                                                                                                                                                                                                                                           {
                                                                                                                                                                                                                                                                                                                               ColorType = PngColorType.TruecolorWithAlpha,
                                                                                                                                                                                                                                                                                                                               Source = new FileCreateSource("tempFile")
                                                                                                                                                                                                                                                                                                                           },
                                                                                                                                                                                                                                                                                                                   BackgroundReplacementColor = Color.Transparent
                                                                                                                                                                                                                                                                   };

                                                                                                                                                                                                                                                                   results = new ImageMasking(image).Decompose(options);
                                                                                                                                                                                                                                                               }

                                                                                                                                                                                                                                                               using (RasterImage resultImage = (RasterImage)results[1].GetImage())
                                                                                                                                                                                                                                                               {
                                                                                                                                                                                                                                                                   resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
                                                                                                                                                                                                                                                               }

Tiết kiệm kết quả mặt nạ hình ảnh với tính toán dựa trên kích cỡ ảnh. Image masking được thực hiện bằng cách sử dụng tự động calculated default strokes. Thêm vào đó, dữ liệu của hai đối tượng giả định cũng được xác định trong AssumedObjects thuộc tính của AutoMaskingGraphCutOptions.

List<assumedobjectdata> assumedObjects = new List<assumedobjectdata>();
                                                                                                                                                                                                                                                                                  assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Human, new Rectangle(100, 100, 150, 300)));
                                                                                                                                                                                                                                                                                  assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Dog, new Rectangle(300, 100, 50, 30)));

                                                                                                                                                                                                                                                                                  MaskingResult[] results;
                                                                                                                                                                                                                                                                                  using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
                                                                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                                                                      AutoMaskingGraphCutOptions options = new AutoMaskingGraphCutOptions
                                                                                                                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                                                                                                                      AssumedObjects = assumedObjects,
                                                                                                                                                                                                                                                                                                                                      CalculateDefaultStrokes = true,
                                                                                                                                                                                                                                                                                                                                      FeatheringRadius = (Math.Max(image.Width, image.Height) / 500) + 1,
                                                                                                                                                                                                                                                                                                                                      Method = SegmentationMethod.GraphCut,
                                                                                                                                                                                                                                                                                                                                      Decompose = false,
                                                                                                                                                                                                                                                                                                                                      ExportOptions =
                                                                                                                                                                                                                                                                                                                                          new PngOptions()
                                                                                                                                                                                                                                                                                                                                              {
                                                                                                                                                                                                                                                                                                                                                  ColorType = PngColorType.TruecolorWithAlpha,
                                                                                                                                                                                                                                                                                                                                                  Source = new FileCreateSource("tempFile")
                                                                                                                                                                                                                                                                                                                                              },
                                                                                                                                                                                                                                                                                                                                      BackgroundReplacementColor = Color.Transparent
                                                                                                                                                                                                                                                                                      };

                                                                                                                                                                                                                                                                                      results = new ImageMasking(image).Decompose(options);
                                                                                                                                                                                                                                                                                  }

                                                                                                                                                                                                                                                                                  using (RasterImage resultImage = (RasterImage)results[1].GetImage())
                                                                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                                                                      resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
                                                                                                                                                                                                                                                                                  }</assumedobjectdata></assumedobjectdata>

Tiết kiệm Graph Cut image masking result with feathering set to 3. hình ảnh mask is performed using specified Point array.

MaskingResult[] results;
                                                                                                                                  using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
                                                                                                                                  {
                                                                                                                                      GraphCutMaskingOptions options = new GraphCutMaskingOptions()
                                                                                                                                                                                  {
                                                                                                                                                                                      FeatheringRadius = 3,
                                                                                                                                                                                      Method = SegmentationMethod.GraphCut,
                                                                                                                                                                                      Decompose = false,
                                                                                                                                                                                      ExportOptions =
                                                                                                                                                                                          new PngOptions()
                                                                                                                                                                                              {
                                                                                                                                                                                                  ColorType = PngColorType.TruecolorWithAlpha,
                                                                                                                                                                                                  Source = new FileCreateSource("tempFile")
                                                                                                                                                                                              },
                                                                                                                                                                                      BackgroundReplacementColor = Color.Transparent,
                                                                                                                                                                                      Args = new AutoMaskingArgs()
                                                                                                                                                                                              {
                                                                                                                                                                                                  ObjectsPoints = new Point[][]
                                                                                                                                                                                                                      {
                                                                                                                                                                                                                          new Point[]
                                                                                                                                                                                                                              {
                                                                                                                                                                                                                                  new Point(100, 100),
                                                                                                                                                                                                                              },
                                                                                                                                                                                                                      }
                                                                                                                                                                                              }
                                                                                                                                                                                  };

                                                                                                                                      results = new ImageMasking(image).Decompose(options);
                                                                                                                                  }

                                                                                                                                  using (RasterImage resultImage = (RasterImage)results[1].GetImage())
                                                                                                                                  {
                                                                                                                                      resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
                                                                                                                                  }

Tiết kiệm kết quả mặt nạ hình ảnh bằng cách nhấp chuột dựa trên kích cỡ ảnh và tái sử dụng các tùy chọn mặt Nạ cho iteration mới. Image masking được thực hiện bằng phương tiện tự động tính toán các tác động mặc định. Ngoài ra, dữ liệu của hai đối tượng được giả định cũng được xác định trong tài sản của AssumedObjects của AutoMaskingGraphCutOptions. Sau khi nhận được kết thúc đầu tiên, áp dụng background/foreground tác hại được sửa đổi và một tác phẩm khác được làm theo.

List<assumedobjectdata> assumedObjects = new List<assumedobjectdata>();
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Human, new Rectangle(100, 100, 150, 300)));
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Dog, new Rectangle(300, 100, 50, 30)));

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  MaskingResult[] results;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  AutoMaskingGraphCutOptions options;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      options = new AutoMaskingGraphCutOptions
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          AssumedObjects = assumedObjects,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          CalculateDefaultStrokes = true,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          FeatheringRadius = 3,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Method = SegmentationMethod.GraphCut,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Decompose = false,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ExportOptions =
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              new PngOptions()
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ColorType = PngColorType.TruecolorWithAlpha,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Source = new FileCreateSource("tempFile")
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  },
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          BackgroundReplacementColor = Color.Transparent
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      };

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      results = new ImageMasking(image).Decompose(options);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  }

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  // At this point applied foreground/background strokes can be analyzed and based on it additional 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  // foreground/background strokes can be manually provided.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Point[] appliedBackgroundStrokes = options.DefaultBackgroundStrokes;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Point[] appliedForegroundStrokes = options.DefaultForegroundStrokes;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Rectangle[] appliedObjectRectangles = options.DefaultObjectsRectangles;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  using (RasterImage resultImage = (RasterImage)results[1].GetImage())
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  }

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      // Re-using AutoMaskingGraphCutOptions there is no need to perform default strokes calculations second time.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      options.CalculateDefaultStrokes = false;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      // When both default strokes and ObjectsPoints in the Args property of AutoMaskingArgs are provided, Point arrays are end up combined.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      // The first ObjectsPoints array is considered to be a background points array and 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      // the second ObjectsPoints array is considered to be a foreground points array.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      // When both DefaultObjectsRectangles and ObjectsRectangles in the Args property of AutoMaskingArgs are provided, 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      // only the array from the Args is being used.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      options.Args = new AutoMaskingArgs()
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ObjectsPoints = new Point[][]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      new Point[] { new Point(100, 100), new Point(150, 100) }, 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      new Point[] { new Point(500, 200) }, 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  },
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ObjectsRectangles = new Rectangle[]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          new Rectangle(100, 100, 300, 300), 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          };
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      results = new ImageMasking(image).Decompose(options);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  }

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  using (RasterImage resultImage = (RasterImage)results[1].GetImage())
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  }</assumedobjectdata></assumedobjectdata>

Tiết kiệm kết quả mặt nạ hình ảnh dựa trên kích cỡ ảnh, sửa đổi các vết nứt mặc định được thu được và sử dụng nó cho iteration trang điểm mới. Image masking được thực hiện bằng cách tự động tính toán các cú đố giả định. Thêm vào đó, dữ liệu của hai đối tượng dự đoán cũng được chỉ định trong tài sản AssumedObjects của AutoMaskingGraphCutOptions. Sau khi nhận được kết cục đầu tiên, áp dụng background/foreground strokes được thay đổi và một lần nữa mặt Nạ Iterations được tiến hành với ứng dụng mới GraphCotMaskinOption.

List<assumedobjectdata> assumedObjects = new List<assumedobjectdata>();
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Human, new Rectangle(100, 100, 150, 300)));
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Dog, new Rectangle(300, 100, 50, 30)));

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                MaskingResult[] results;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                AutoMaskingGraphCutOptions options;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    options = new AutoMaskingGraphCutOptions
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        AssumedObjects = assumedObjects,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        CalculateDefaultStrokes = true,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        FeatheringRadius = 3,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Method = SegmentationMethod.GraphCut,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Decompose = false,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ExportOptions =
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            new PngOptions()
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ColorType = PngColorType.TruecolorWithAlpha,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Source = new FileCreateSource("tempFile")
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                },
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        BackgroundReplacementColor = Color.Transparent
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    };

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    results = new ImageMasking(image).Decompose(options);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                }

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                // At this point applied foreground/background strokes can be analyzed and based on it additional 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                // foreground/background strokes can be manually provided.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Point[] appliedBackgroundStrokes = options.DefaultBackgroundStrokes;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Point[] appliedForegroundStrokes = options.DefaultForegroundStrokes;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Rectangle[] appliedObjectRectangles = options.DefaultObjectsRectangles;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                using (RasterImage resultImage = (RasterImage)results[1].GetImage())
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                }

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                appliedBackgroundStrokes[5] = new Point(100, 100);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                appliedBackgroundStrokes[15] = new Point(150, 100);

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                appliedForegroundStrokes[1] = new Point(500, 200);

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                appliedObjectRectangles[0] = new Rectangle(100, 100, 300, 300);

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    GraphCutMaskingOptions graphCutOptions = new GraphCutMaskingOptions()
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        FeatheringRadius = 3,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Method = SegmentationMethod.GraphCut,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Decompose = false,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ExportOptions = new PngOptions()
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ColorType = PngColorType.TruecolorWithAlpha,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Source = new FileCreateSource("tempFile")
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            },
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        BackgroundReplacementColor = Color.Transparent,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Args = new AutoMaskingArgs()
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ObjectsPoints = new Point[][]
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            appliedBackgroundStrokes,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            appliedForegroundStrokes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        },
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ObjectsRectangles = appliedObjectRectangles
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    };
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    results = new ImageMasking(image).Decompose(graphCutOptions);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                }

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                using (RasterImage resultImage = (RasterImage)results[1].GetImage())
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                }</assumedobjectdata></assumedobjectdata>
 Tiếng Việt