Class MagicWandSettings
Le nom : Aspose.Imaging.MagicWand Assemblée: Aspose.Imaging.dll (25.4.0)
Un classement de sélection magique.
public class MagicWandSettings
Inheritance
I membri ereditari
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
L’exemple montre comment sélectionner une zone simple d’une image en fonction du ton et de la couleur de tout pixel en utilisant l’outil 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
});
}
L’exemple montre comment sélectionner une zone compliquée d’une image en utilisant l’outil Magic Wand et la capacité à interagir avec les masques (invert, union, substrat).
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
MagicWandSettings(Point)
Initialisez une nouvelle instance de la classe Aspose.Imaging.MagicWand.
public MagicWandSettings(Point point)
Parameters
point
Point
Le point de référence.
MagicWandSettings(int, int)
Initialisez une nouvelle instance de la classe Aspose.Imaging.MagicWand.
public MagicWandSettings(int x, int y)
Parameters
x
int
Le coordonné x du point de référence.
y
int
la coordonnée du point de référence.
Properties
AreaOfInterest
Obtenez ou mettez les limites de la zone pour le travail algorithmique.
public Rectangle AreaOfInterest { get; set; }
Valore di proprietà
ColorCompareMode
Obtenez ou définissez l’algorithme de la façon dont les couleurs sont comparées.
public ColorComparisonMode ColorCompareMode { get; set; }
Valore di proprietà
ColorComparisonDelegate
Obtenez ou définissez l’algorithme de comparaison de couleur personnalisée si Aspose.Imaging.MagicWand.MAGICWANDSettings.ColorCompareMode est configuré à __ WL16__ .MagikWanda.COLORComparisonMODE.
public MagicWandSettings.ColorComparison ColorComparisonDelegate { get; set; }
Valore di proprietà
MagicWandSettings . ColorComparison
ContiguousMode
Obtenez ou définissez une valeur indiquant si le wand magique ne définira que des pixels contagieux.
public bool ContiguousMode { get; set; }
Valore di proprietà
DirectionalMode
Obtenez ou définissez le mode d’inondation pour remplir l’algorithme de recherche: quatre des huit directions de la recherche.
public FloodFillDirectionalMode DirectionalMode { get; set; }
Valore di proprietà
Point
Obtenez ou définissez le point de référence pour le travail algorithmique.
public Point Point { get; }
Valore di proprietà
Threshold
Obtenez ou définissez le niveau de tolérance pour la comparaison des pixels de couleur.
public int Threshold { get; set; }