Class MagicWandTool
Tên không gian: Aspose.Imaging.MagicWand Tổng hợp: Aspose.Imaging.dll (25.4.0)
Các lớp học cho phép thuật wand thuật toán logic chính.
public class MagicWandTool : IPartialArgb32PixelLoader
Inheritance
Implements
Thành viên thừa kế
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
Ví dụ cho thấy làm thế nào để chọn một khu vực đơn giản của một hình ảnh dựa trên âm thanh và màu sắc của bất kỳ pixel bằng cách sử dụng công cụ 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
});
}
Ví dụ cho thấy cách chọn một khu vực phức tạp của một hình ảnh bằng cách sử dụng công cụ Magic Wand và khả năng tương tác với mặt nạ (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(Vị trí, int[ ], Điểm, Điểm)
Xử lý các pixel tải.
public void Process(Rectangle pixelsRectangle, int[] pixels, Point start, Point end)
Parameters
pixelsRectangle
Rectangle
Các pixel trực tiếp.
pixels
int
[ ]
Các 32-bit ARGB pixel.
start
Point
Nếu không bình đẳng với (trên trái, trên) có nghĩa là nó không phải là một góc thẳng đầy đủ chúng ta có.
end
Point
Nếu không bình đẳng với (tên phải, dưới cùng) có nghĩa là nó không phải là một góc thẳng đầy đủ chúng ta có.
Select(Hướng dẫn cài đặt MagicWandSettings)
Tạo một Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask mới dựa trên Wl17. Magic Wand và các cài đặt và tài nguyên _www.rasterimage.
public static ImageBitMask Select(RasterImage source, MagicWandSettings settings)
Parameters
source
RasterImage
Raster hình ảnh cho các thuật toán để làm việc qua.
settings
MagicWandSettings
Cài đặt của thuật toán wand ma thuật được sử dụng trong việc tạo ra mặt nạ.
Returns
Mới Aspose.Imaging.MagicWand.ImageMasks.ImagicBitMask.