Class MagicWandTool

Class MagicWandTool

ชื่อพื้นที่: Aspose.Imaging.MagicWand การประกอบ: Aspose.Imaging.dll (25.4.0)

คลาสสําหรับวิงวดวิง algorithm โลกหลัก

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

ตัวอย่างนี้แสดงให้เห็นวิธีการเลือกพื้นที่ที่เรียบง่ายของภาพขึ้นอยู่กับสีและสีของ pixels โดยใช้เครื่องมือ 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 และความสามารถในการโต้ตอบกับ mask (invert, union, substract)

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[ ], จุด , จุด)

การประมวลผลของ pixels ที่โหลด

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

Parameters

pixelsRectangle Rectangle

พิกเซลที่ตรง

pixels int [ ]

พิกเซล ARGB 32 บิต

start Point

พิกเซลเริ่มต้นจุด ถ้าไม่เท่ากับ (ด้านซ้าย, ด้านบน) ซึ่งหมายความว่ามันไม่ได้เป็นแนวตั้งที่สมบูรณ์ที่เรามี

end Point

พิกเซลปลายจุด ถ้าไม่เท่ากับ (ขวา, ด้านล่าง) ซึ่งหมายความว่ามันไม่ได้เป็นขวาที่สมบูรณ์ที่เรามี

Select(RasterImage, 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 สําหรับ algorithm เพื่อทํางานผ่าน

settings MagicWandSettings

การตั้งค่าของแอลกอฮอร์โมนวิง Magic ใช้ในการสร้างหน้ากาก

Returns

ImageBitMask

ใหม่ Aspose.Imaging.MagicWand.ImageMasks.ImageBitMask.

 แบบไทย