Class MagicWandTool

Class MagicWandTool

名称: Aspose.Imaging.MagicWand 收藏: Aspose.Imaging.dll (25.4.0)

魔法 wand算法的课堂主要逻辑。

public class MagicWandTool : IPartialArgb32PixelLoader

Inheritance

object MagicWandTool

Implements

IPartialArgb32PixelLoader

继承人

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

Examples

示例显示如何选择一个简单的图像区域,基于任何像素的色调和颜色,使用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
                                                                                                                                    });
                                                                                                                                }

示例显示如何使用 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 (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(直角, int( ), 点,点)

处理负载的像素。

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

Parameters

pixelsRectangle Rectangle

像素直角。

pixels int ( )

32 位 ARGB 像素

start Point

如果不等于(左,顶)意味着它不是完整的直角我们有。

end Point

如果不等于(右,底)意味着它不是完整的直角我们有。

Select(首頁 〉外文書 〉文學 〉MagicWandSettings)

创建一个新的 Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask 基于 Aspose.Imaging.MagicWand.MagicWandSettings 和源 Aspose.Imaging.RasterImage。

public static ImageBitMask Select(RasterImage source, MagicWandSettings settings)

Parameters

source RasterImage

Raster 图像,以便算法完成工作。

settings MagicWandSettings

设置魔法 wand 算法用于创建面具。

Returns

ImageBitMask

新 Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask.

 中文