Class ImageMask

Class ImageMask

Il nome: Aspose.Imaging.MagicWand.ImageMasks Assemblea: Aspose.Imaging.dll (25.4.0)

Descrive una maschera di immagine binaria.

public abstract class ImageMask : IImageMask, ICloneable

Inheritance

object ImageMask

Derived

CircleMask , EmptyImageMask , ImageBitMask , RectangleMask

Implements

IImageMask , ICloneable

I membri ereditari

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

Examples

L’esempio mostra come selezionare una zona complicata di un’immagine utilizzando Magic Wand tool e la capacità di interagire con le maschere (invert, union, substrato).

var imageFilePath = "input.png"; 
                                                                                                                                                                  using (RasterImage image = (RasterImage)Image.Load(inputFilePath))
                                                                                                                                                                  {
                                                                                                                                                                      // Create a new mask using magic wand tool based on tone and color of pixel (845, 128)
                                                                                                                                                                      MagicWandTool.Select(image, new MagicWandSettings(845, 128))
                                                                                                                                                                          // Union the existing mask with the specified one created by magic wand tool
                                                                                                                                                                          .Union(new MagicWandSettings(416, 387))
                                                                                                                                                                          // Invert the existing mask
                                                                                                                                                                          .Invert()
                                                                                                                                                                          // Subtract the specified mask created by magic wand tool with specified threshold from the existing one 
                                                                                                                                                                          .Subtract(new MagicWandSettings(1482, 346) { Threshold = 69 })
                                                                                                                                                                          // Subtract four specified rectangle masks from the existing mask one by one
                                                                                                                                                                          .Subtract(new RectangleMask(0, 0, 800, 150))
                                                                                                                                                                          .Subtract(new RectangleMask(0, 380, 600, 220))
                                                                                                                                                                          .Subtract(new RectangleMask(930, 520, 110, 40))
                                                                                                                                                                          .Subtract(new RectangleMask(1370, 400, 120, 200))
                                                                                                                                                                          // Feather mask with specified settings
                                                                                                                                                                          .GetFeathered(new FeatheringSettings() { Size = 3 })
                                                                                                                                                                          // Apply mask to the image
                                                                                                                                                                          .Apply();

                                                                                                                                                                      // Save image
                                                                                                                                                                      image.Save(outputFilePath);
                                                                                                                                                                  }

Constructors

ImageMask(di int, int)

Inizia una nuova instanza della classe Aspose.Imaging.MagicWand.ImageMasks. ImageMask con la larghezza e l’altezza specificate.

protected ImageMask(int width, int height)

Parameters

width int

La larghezza della maschera.

height int

L’altezza della maschera.

Properties

Bounds

Ricevi i limiti, in pixel, di questa maschera.

public Rectangle Bounds { get; }

Valore di proprietà

Rectangle

Height

Ricevi l’altezza, in pixel, di questa maschera.

public int Height { get; protected set; }

Valore di proprietà

int

SelectionBounds

Riceve i confini della parte selezionata della maschera, in pixel.

public abstract Rectangle SelectionBounds { get; }

Valore di proprietà

Rectangle

Source

Riceve l’immagine sorgente utilizzata per creare questa maschera, se esiste.

public RasterImage Source { get; protected set; }

Valore di proprietà

RasterImage

Width

Ricevi la larghezza, in pixel, di questa maschera.

public int Width { get; protected set; }

Valore di proprietà

int

Questo[di int, int]

Riceve l’opacità del pixel specificato.

public abstract bool this[int x, int y] { get; }

Valore di proprietà

bool

Methods

Apply()

Applicare la maschera corrente alla fonte Aspose.Imaging.RasterImage, se esiste.

public void Apply()

Examples

L’esempio mostra come selezionare una semplice area di un’immagine sulla base del tono e del colore di qualsiasi pixel utilizzando Magic Wand tool.

var imageFilePath = "input.png"; 
                                                                                                                                using (RasterImage image = (RasterImage)Image.Load(inputFilePath))
                                                                                                                                {
                                                                                                                                    // Create a new mask using magic wand tool based on tone and color of pixel (120, 100) with custom threshold equal to 150
                                                                                                                                    MagicWandTool
                                                                                                                                        .Select(image, new MagicWandSettings(120, 100) { Threshold = 150 })
                                                                                                                                        // Apply mask to the image
                                                                                                                                        .Apply();

                                                                                                                                    // Save image with forced transparency color type option
                                                                                                                                    image.Save(outputFilePath, new ImageOptions.PngOptions()
                                                                                                                                    {
                                                                                                                                        ColorType = PngColorType.TruecolorWithAlpha
                                                                                                                                    });
                                                                                                                                }

Exceptions

NullReferenceException

Ritorno quando l’immagine fonte non è definita.

ApplyTo(RasterImage)

Applicare la maschera corrente alla specifica Aspose.Imaging.RasterImage.

public void ApplyTo(RasterImage image)

Parameters

image RasterImage

Immagine per applicare la maschera.

Exceptions

ArgumentNullException

Ritorno quando l’immagine non è definita.

Clone()

Crea un nuovo oggetto che è una copia dell’attuale instanza.

public abstract object Clone()

Returns

object

Un nuovo oggetto che è una copia di questa instanza.

Crop(Size)

La maschera con la dimensione specificata.

public ImageMask Crop(Size size)

Parameters

size Size

La dimensione specificata.

Returns

ImageMask

Una maschera immagine.

Crop(di int, int)

La maschera di croce con la larghezza e l’altezza specificate.

public ImageMask Crop(int width, int height)

Parameters

width int

La larghezza specificata.

height int

L’altezza specificata.

Returns

ImageMask

Una maschera immagine.

Crop(Rectangle)

La maschera con il rectangolo specificato.

public abstract ImageMask Crop(Rectangle rectangle)

Parameters

rectangle Rectangle

Il rectangolo specificato.

Returns

ImageMask

Una maschera immagine.

ExclusiveDisjunction(ImageMask)

Riceve l’esclusiva disunzione della maschera corrente con fornito.

public ImageBitMask ExclusiveDisjunction(ImageMask mask)

Parameters

mask ImageMask

La maschera offerta

Returns

ImageBitMask

Nuovo Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask.

ExclusiveDisjunction(MagicWandSettings)

Riceve l’esclusiva disunzione della maschera corrente con il risultato della selezione magica di wand applicata alla sorgente della maskera.

public ImageBitMask ExclusiveDisjunction(MagicWandSettings settings)

Parameters

settings MagicWandSettings

Impostazioni di Magic Wand.

Returns

ImageBitMask

Nuovo Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask.

Exceptions

ArgumentNullException

L’immagine di sorgente non è definita nella maschera.

ExclusiveDisjunction(Sito ufficiale: MagicWandSettings)

Riceve l’esclusiva disunzione della maschera corrente con il risultato della selezione magica di Wand applicata all’immagine fornita.

public ImageBitMask ExclusiveDisjunction(RasterImage image, MagicWandSettings settings)

Parameters

image RasterImage

Immagini di Magic Wand.

settings MagicWandSettings

Impostazioni di Magic Wand.

Returns

ImageBitMask

Nuovo Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask.

GetByteOpacity(di int, int)

Riceve l’opacità del pixel specificato con precisione byte.

public byte GetByteOpacity(int x, int y)

Parameters

x int

Il coordinato x del pixel.

y int

Il coordinato y del pixel.

Returns

byte

Valore byte, che rappresenta l’opacità del pixel specificato.

GetFeathered(FeatheringSettings)

Riceve la maschera di griglia con la frontiera affinata con le impostazioni specificate.

public ImageGrayscaleMask GetFeathered(FeatheringSettings settings = null)

Parameters

settings FeatheringSettings

Impostazioni di fiducia.

Returns

ImageGrayscaleMask

Aspose.Imaging.MagicWand.ImageMasks.ImmageGrayscaleMask con confine fissate.

Inflate(int)

Inflazione di questa maschera per la quantità specificata.

public abstract ImageMask Inflate(int size)

Parameters

size int

La quantità per infondere questa maschera.

Returns

ImageMask

Una maschera immagine.

Intersect(ImageMask)

Riceve la intersezione della maschera corrente con la fornitura.

public ImageBitMask Intersect(ImageMask mask)

Parameters

mask ImageMask

La maschera offerta

Returns

ImageBitMask

Nuovo Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask.

Intersect(MagicWandSettings)

Riceve l’intersezione della maschera corrente con il risultato della selezione magica di Wand applicata alla sorgente del maschio.

public ImageBitMask Intersect(MagicWandSettings settings)

Parameters

settings MagicWandSettings

Impostazioni di Magic Wand.

Returns

ImageBitMask

Nuovo Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask.

Exceptions

ArgumentNullException

L’immagine di sorgente non è definita nella maschera.

Intersect(Sito ufficiale: MagicWandSettings)

Riceve l’intersezione della maschera corrente con il risultato della selezione magica di Wand applicata all’immagine fornita.

public ImageBitMask Intersect(RasterImage image, MagicWandSettings settings)

Parameters

image RasterImage

Immagini di Magic Wand.

settings MagicWandSettings

Impostazioni di Magic Wand.

Returns

ImageBitMask

Nuovo Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask.

Invert()

Riceve l’inversione della maschera corrente.

public ImageBitMask Invert()

Returns

ImageBitMask

Nuovo Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask.

Examples

L’esempio mostra come selezionare una zona complicata di un’immagine utilizzando Magic Wand tool e la capacità di interagire con le maschere (invert, union, substrato).

var imageFilePath = "input.png"; 
                                                                                                                                                                  using (RasterImage image = (RasterImage)Image.Load(inputFilePath))
                                                                                                                                                                  {
                                                                                                                                                                      // Create a new mask using magic wand tool based on tone and color of pixel (845, 128)
                                                                                                                                                                      MagicWandTool.Select(image, new MagicWandSettings(845, 128))
                                                                                                                                                                          // Union the existing mask with the specified one created by magic wand tool
                                                                                                                                                                          .Union(new MagicWandSettings(416, 387))
                                                                                                                                                                          // Invert the existing mask
                                                                                                                                                                          .Invert()
                                                                                                                                                                          // Subtract the specified mask created by magic wand tool with specified threshold from the existing one 
                                                                                                                                                                          .Subtract(new MagicWandSettings(1482, 346) { Threshold = 69 })
                                                                                                                                                                          // Subtract four specified rectangle masks from the existing mask one by one
                                                                                                                                                                          .Subtract(new RectangleMask(0, 0, 800, 150))
                                                                                                                                                                          .Subtract(new RectangleMask(0, 380, 600, 220))
                                                                                                                                                                          .Subtract(new RectangleMask(930, 520, 110, 40))
                                                                                                                                                                          .Subtract(new RectangleMask(1370, 400, 120, 200))
                                                                                                                                                                          // Feather mask with specified settings
                                                                                                                                                                          .GetFeathered(new FeatheringSettings() { Size = 3 })
                                                                                                                                                                          // Apply mask to the image
                                                                                                                                                                          .Apply();

                                                                                                                                                                      // Save image
                                                                                                                                                                      image.Save(outputFilePath);
                                                                                                                                                                  }

IsOpaque(di int, int)

Verifica se il pixel specificato è opaco.

public bool IsOpaque(int x, int y)

Parameters

x int

Il coordinato x del pixel.

y int

Il coordinato y del pixel.

Returns

bool

vero se il pixel specificato è opaco; altrimenti, falso.

IsTransparent(di int, int)

Verifica se il pixel specificato è trasparente.

public bool IsTransparent(int x, int y)

Parameters

x int

Il coordinato x del pixel.

y int

Il coordinato y del pixel.

Returns

bool

vero se il pixel specificato è trasparente; altrimenti, falso.

Subtract(ImageMask)

Riceve la sottrazione della maschera fornita dal corrente.

public ImageBitMask Subtract(ImageMask mask)

Parameters

mask ImageMask

La maschera offerta

Returns

ImageBitMask

Nuovo Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask.

Examples

L’esempio mostra come selezionare una zona complicata di un’immagine utilizzando Magic Wand tool e la capacità di interagire con le maschere (invert, union, substrato).

var imageFilePath = "input.png"; 
                                                                                                                                                                  using (RasterImage image = (RasterImage)Image.Load(inputFilePath))
                                                                                                                                                                  {
                                                                                                                                                                      // Create a new mask using magic wand tool based on tone and color of pixel (845, 128)
                                                                                                                                                                      MagicWandTool.Select(image, new MagicWandSettings(845, 128))
                                                                                                                                                                          // Union the existing mask with the specified one created by magic wand tool
                                                                                                                                                                          .Union(new MagicWandSettings(416, 387))
                                                                                                                                                                          // Invert the existing mask
                                                                                                                                                                          .Invert()
                                                                                                                                                                          // Subtract the specified mask created by magic wand tool with specified threshold from the existing one 
                                                                                                                                                                          .Subtract(new MagicWandSettings(1482, 346) { Threshold = 69 })
                                                                                                                                                                          // Subtract four specified rectangle masks from the existing mask one by one
                                                                                                                                                                          .Subtract(new RectangleMask(0, 0, 800, 150))
                                                                                                                                                                          .Subtract(new RectangleMask(0, 380, 600, 220))
                                                                                                                                                                          .Subtract(new RectangleMask(930, 520, 110, 40))
                                                                                                                                                                          .Subtract(new RectangleMask(1370, 400, 120, 200))
                                                                                                                                                                          // Feather mask with specified settings
                                                                                                                                                                          .GetFeathered(new FeatheringSettings() { Size = 3 })
                                                                                                                                                                          // Apply mask to the image
                                                                                                                                                                          .Apply();

                                                                                                                                                                      // Save image
                                                                                                                                                                      image.Save(outputFilePath);
                                                                                                                                                                  }

Subtract(MagicWandSettings)

Riceve il risultato della selezione magica di Wand applicata alla fonte della maschera corrente sottrazione dalla mascherata.

public ImageBitMask Subtract(MagicWandSettings settings)

Parameters

settings MagicWandSettings

Impostazioni di Magic Wand.

Returns

ImageBitMask

Nuovo Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask.

Exceptions

ArgumentNullException

L’immagine di sorgente non è definita nella maschera.

Subtract(Sito ufficiale: MagicWandSettings)

Riceve il risultato della selezione magica di Wand applicata all’immagine fornita sottrazione dalla maschera corrente.

public ImageBitMask Subtract(RasterImage image, MagicWandSettings settings)

Parameters

image RasterImage

Immagini di Magic Wand.

settings MagicWandSettings

Impostazioni di Magic Wand.

Returns

ImageBitMask

Nuovo Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask.

Union(ImageMask)

Riceve l’unione della maschera corrente con la fornitura.

public ImageBitMask Union(ImageMask mask)

Parameters

mask ImageMask

La maschera offerta

Returns

ImageBitMask

Nuovo Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask.

Examples

L’esempio mostra come selezionare una zona complicata di un’immagine utilizzando Magic Wand tool e la capacità di interagire con le maschere (invert, union, substrato).

var imageFilePath = "input.png"; 
                                                                                                                                                                  using (RasterImage image = (RasterImage)Image.Load(inputFilePath))
                                                                                                                                                                  {
                                                                                                                                                                      // Create a new mask using magic wand tool based on tone and color of pixel (845, 128)
                                                                                                                                                                      MagicWandTool.Select(image, new MagicWandSettings(845, 128))
                                                                                                                                                                          // Union the existing mask with the specified one created by magic wand tool
                                                                                                                                                                          .Union(new MagicWandSettings(416, 387))
                                                                                                                                                                          // Invert the existing mask
                                                                                                                                                                          .Invert()
                                                                                                                                                                          // Subtract the specified mask created by magic wand tool with specified threshold from the existing one 
                                                                                                                                                                          .Subtract(new MagicWandSettings(1482, 346) { Threshold = 69 })
                                                                                                                                                                          // Subtract four specified rectangle masks from the existing mask one by one
                                                                                                                                                                          .Subtract(new RectangleMask(0, 0, 800, 150))
                                                                                                                                                                          .Subtract(new RectangleMask(0, 380, 600, 220))
                                                                                                                                                                          .Subtract(new RectangleMask(930, 520, 110, 40))
                                                                                                                                                                          .Subtract(new RectangleMask(1370, 400, 120, 200))
                                                                                                                                                                          // Feather mask with specified settings
                                                                                                                                                                          .GetFeathered(new FeatheringSettings() { Size = 3 })
                                                                                                                                                                          // Apply mask to the image
                                                                                                                                                                          .Apply();

                                                                                                                                                                      // Save image
                                                                                                                                                                      image.Save(outputFilePath);
                                                                                                                                                                  }

Union(MagicWandSettings)

Riceve l’unione della maschera corrente con il risultato della selezione magica di Wand applicata alla sorgente del maschio.

public ImageBitMask Union(MagicWandSettings settings)

Parameters

settings MagicWandSettings

Impostazioni di Magic Wand.

Returns

ImageBitMask

Nuovo Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask.

Exceptions

ArgumentNullException

L’immagine di sorgente non è definita nella maschera.

Union(Sito ufficiale: MagicWandSettings)

Riceve l’unione della maschera corrente con il risultato della selezione magica di Wand applicata all’immagine fornita.

public ImageBitMask Union(RasterImage image, MagicWandSettings settings)

Parameters

image RasterImage

Immagini di Magic Wand.

settings MagicWandSettings

Impostazioni di Magic Wand.

Returns

ImageBitMask

Nuovo Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask.

Operators

Operatore +(Immagini e ImageMask)

Unione di due maschere.

public static ImageBitMask operator +(ImageMask a, ImageMask b)

Parameters

a ImageMask

La prima maschera.

b ImageMask

La seconda maschera.

Returns

ImageBitMask

Nuovo Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask.

operatore(Immagini e ImageMask)

Disunzione esclusiva di due maschere.

public static ImageBitMask operator ^(ImageMask a, ImageMask b)

Parameters

a ImageMask

La prima maschera.

b ImageMask

La seconda maschera.

Returns

ImageBitMask

Nuovo Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask.

Operatore esplicito ImageGrayscaleMask(ImageMask)

Aspose.Imaging.MagicWand.ImageMasks.ImmageGrayscaleMask operatore di casting.

public static explicit operator ImageGrayscaleMask(ImageMask mask)

Parameters

mask ImageMask

Il valore della maschera.

Returns

ImageGrayscaleMask

Il nuovo Aspose.Imaging.MagicWand.ImageMasks. ImageGrayscaleMask.

Operatore !(ImageMask)

La maschera inversa.

public static ImageBitMask operator !(ImageMask a)

Parameters

a ImageMask

La maschera da invertire.

Returns

ImageBitMask

Nuovo Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask.

Operatore *(Immagini e ImageMask)

Intersezione di due maschere.

public static ImageBitMask operator *(ImageMask a, ImageMask b)

Parameters

a ImageMask

La prima maschera.

b ImageMask

La seconda maschera.

Returns

ImageBitMask

Nuovo Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask.

Operatore -(Immagini e ImageMask)

Rimuovere la seconda maschera dal primo.

public static ImageBitMask operator -(ImageMask a, ImageMask b)

Parameters

a ImageMask

La prima maschera.

b ImageMask

La seconda maschera.

Returns

ImageBitMask

Nuovo Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask.

 Italiano