Class MagicWandSettings
Tên không gian: Aspose.Imaging.MagicWand Tổng hợp: Aspose.Imaging.dll (25.4.0)
A magic wand selection cài đặt lớp.
public class MagicWandSettings
Inheritance
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);
}
Constructors
MagicWandSettings(Point)
Bắt đầu một trường hợp mới của lớp Aspose.Imaging.MagicWand.Mágic WandSettings.
public MagicWandSettings(Point point)
Parameters
point
Point
điểm tham chiếu.
MagicWandSettings(int, int)
Bắt đầu một trường hợp mới của lớp Aspose.Imaging.MagicWand.Mágic WandSettings.
public MagicWandSettings(int x, int y)
Parameters
x
int
X-coordinate của điểm tham chiếu.
y
int
Y-tương thích của điểm tham chiếu.
Properties
AreaOfInterest
Nhận hoặc đặt giới hạn của khu vực cho công việc thuật toán.
public Rectangle AreaOfInterest { get; set; }
Giá trị bất động sản
ColorCompareMode
Nhận hoặc đặt thuật toán làm thế nào màu sắc được so sánh.
public ColorComparisonMode ColorCompareMode { get; set; }
Giá trị bất động sản
ColorComparisonDelegate
Nhận hoặc cài đặt thuật toán so sánh màu tùy chỉnh nếu Aspose.Imaging.MagicWand.MàuSettings.ColorCompareMode được thiết lập để Wl17.
public MagicWandSettings.ColorComparison ColorComparisonDelegate { get; set; }
Giá trị bất động sản
MagicWandSettings . ColorComparison
ContiguousMode
Nhận hoặc đặt một giá trị cho thấy liệu Magic Wand sẽ chỉ định các pixel liên quan.
public bool ContiguousMode { get; set; }
Giá trị bất động sản
DirectionalMode
Nhận hoặc đặt chế độ lũ lụt lấp đầy thuật toán tìm kiếm: bốn trong tám hướng Tìm kiếm.
public FloodFillDirectionalMode DirectionalMode { get; set; }
Giá trị bất động sản
Point
Nhận hoặc đặt điểm tham chiếu cho công việc thuật toán.
public Point Point { get; }
Giá trị bất động sản
Threshold
Nhận hoặc đặt mức độ dung nạp cho so sánh màu pixel.
public int Threshold { get; set; }