Class ManualMaskingArgs

Class ManualMaskingArgs

Namespace: Aspose.Imaging.Masking.Options
Assembly: Aspose.Imaging.dll (25.7.0)

Represents the arguments that are specified for manual masking method

public class ManualMaskingArgs : IMaskingArgs
   {
       public string FieldName { get; set; }
       public string FieldValue { get; set; }
       public bool MaskPrintedValue { get; set; }
   }

Inheritance

object ManualMaskingArgs

Implements

IMaskingArgs

Inherited Members

object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

This example shows how to decompose a raster image into multiple images using image masking and a manual mask. Image masking is an image processing technique that is used to split the background from the foreground image objects.

string dir = "c:\\temp\\";
   Aspose.Imaging.GraphicsPath manualMask = new Aspose.Imaging.GraphicsPath();
   Aspose.Imaging.Figure figure = new Aspose.Imaging.Figure();
   figure.AddShape(new Aspose.Imaging.Shapes.EllipseShape(new RectangleF(50, 50, 40, 40)));
   figure.AddShape(new Aspose.Imaging.Shapes.RectangleShape(new RectangleF(10, 20, 50, 30)));
   manualMask.AddFigure(figure);
   Aspose.Imaging.ImageOptions.PngOptions exportOptions = new Aspose.Imaging.ImageOptions.PngOptions();
   exportOptions.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha;
   exportOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream());
   Aspose.Imaging.Masking.Options.ManualMaskingArgs args = new Aspose.Imaging.Masking.Options.ManualMaskingArgs();
   args.Mask = manualMask;
   using (RasterImage image = (RasterImage)Image.Load(dir + "Blue hills.png"))
   {
       Aspose.Imaging.Masking.Options.MaskingOptions maskingOptions = new Aspose.Imaging.Masking.Options.MaskingOptions();
       maskingOptions.Method = Masking.Options.SegmentationMethod.Manual;
       maskingOptions.Decompose = false;
       maskingOptions.Args = args;
       maskingOptions.BackgroundReplacementColor = Aspose.Imaging.Color.Orange;
       maskingOptions.ExportOptions = exportOptions;
       maskingOptions.MaskingArea = new Rectangle(50, 50, 120, 120);
       Aspose.Imaging.Masking.ImageMasking masking = new Aspose.Imaging.Masking.ImageMasking(image);
       using (Aspose.Imaging.Masking.Result.MaskingResult maskingResult = masking.Decompose(maskingOptions))
       {
           for (int i = 0; i < maskingResult.Length; i++)
           {
               string outputFileName = string.Format("Blue hills.Segment{0}.png", maskingResult[i].ObjectNumber);
               using (Aspose.Imaging.Image resultImage = maskingResult[i].GetImage())
               {
                   resultImage.Save(dir + outputFileName);
               }
           }
       }
   }

Constructors

ManualMaskingArgs()

public ManualMaskingArgs()
   {
   }

Properties

Mask

Gets or sets the set of graphic shapes that form mask.

public GraphicsPath Mask
   {
      get;
      set;
   }

Property Value

GraphicsPath

Examples

This example shows how to decompose a raster image into multiple images using image masking and a manual mask. Image masking is an image processing technique that is used to split the background from the foreground image objects.

string dir = "c:\\temp\\";
   Aspose.Imaging.GraphicsPath manualMask = new Aspose.Imaging.GraphicsPath();
   Aspose.Imaging.Figure figure = new Aspose.Imaging.Figure();
   figure.AddShape(new Aspose.Imaging.Shapes.EllipseShape(new RectangleF(50, 50, 40, 40)));
   figure.AddShape(new Aspose.Imaging.Shapes.RectangleShape(new RectangleF(10, 20, 50, 30)));
   manualMask.AddFigure(figure);
   Aspose.Imaging.ImageOptions.PngOptions exportOptions = new Aspose.Imaging.ImageOptions.PngOptions();
   exportOptions.ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha;
   exportOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream());
   Aspose.Imaging.Masking.Options.ManualMaskingArgs args = new Aspose.Imaging.Masking.Options.ManualMaskingArgs();
   args.Mask = manualMask;
   using (RasterImage image = (RasterImage)Image.Load(dir + "Blue hills.png"))
   {
       Aspose.Imaging.Masking.Options.MaskingOptions maskingOptions = new Aspose.Imaging.Masking.Options.MaskingOptions();
       maskingOptions.Method = Masking.Options.SegmentationMethod.Manual;
       maskingOptions.Decompose = false;
       maskingOptions.Args = args;
       maskingOptions.BackgroundReplacementColor = Aspose.Imaging.Color.Orange;
       maskingOptions.ExportOptions = exportOptions;
       maskingOptions.MaskingArea = new Rectangle(50, 50, 120, 120);
       Aspose.Imaging.Masking.ImageMasking masking = new Aspose.Imaging.Masking.ImageMasking(image);
       using (Aspose.Imaging.Masking.Result.MaskingResult maskingResult = masking.Decompose(maskingOptions))
       {
           for (int i = 0; i < maskingResult.Length; i++)
           {
               string outputFileName = string.Format("Blue hills.Segment{0}.png", maskingResult[i].ObjectNumber);
               using (Aspose.Imaging.Image resultImage = maskingResult[i].GetImage())
               {
                   resultImage.Save(dir + outputFileName);
               }
           }
       }
   }

See Also

IMaskingArgs

 English