Class MagicWandTool

Class MagicWandTool

Nombre del espacio: Aspose.Imaging.MagicWand Asamblea: Aspose.Imaging.dll (25.4.0)

La clase para el algoritmo de la magia Wand es la lógica principal.

public class MagicWandTool : IPartialArgb32PixelLoader

Inheritance

object MagicWandTool

Implements

IPartialArgb32PixelLoader

Miembros heredados

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

Examples

El ejemplo muestra cómo seleccionar una simple área de una imagen basada en el tono y el color de cualquier pixel utilizando la herramienta Magic Wand.

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
                                                                                                                                    });
                                                                                                                                }

El ejemplo muestra cómo seleccionar una zona complicada de una imagen utilizando la herramienta Magic Wand y la capacidad de interactuar con las máscaras (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);
                                                                                                                                                                  }

Methods

Process(El rectángulo, int[][], El punto, el punto)

Procesar los píxeles cargados.

public void Process(Rectangle pixelsRectangle, int[] pixels, Point start, Point end)

Parameters

pixelsRectangle Rectangle

Los píxeles son rectangulares.

pixels int [][]

Los pixeles ARGB de 32 bits.

start Point

Si no es igual a (leva, arriba) significa que no es un rectángulo completo que tenemos.

end Point

Si no es igual a (derecha, abajo) significa que no es un rectángulo completo que tenemos.

Select(SiguienteSiguienteSiguienteMagicWandSettings)

Crea un nuevo Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask basado en Aspose.Imaging.MagicWand.MagicWandSettings y fuente Aspose.Imaging.RasterImage.

public static ImageBitMask Select(RasterImage source, MagicWandSettings settings)

Parameters

source RasterImage

Imagen raster para que el algoritmo funcione.

settings MagicWandSettings

Establecimientos del algoritmo de wand mágico utilizado en la creación de máscaras.

Returns

ImageBitMask

Nuevos Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask.

 Español