GraphCutMaskingOptions 类
内容
[
隐藏
]Summary: The GraphCut auto masking options.
Module: aspose.imaging.masking.options
Full Name: aspose.imaging.masking.options.GraphCutMaskingOptions
Inheritance: MaskingOptions
Constructors
| Name | 描述 |
|---|---|
| GraphCutMaskingOptions() | 初始化 GraphCutMaskingOptions 类的新实例 |
Properties
| Name | Type | Access | 描述 |
|---|---|---|---|
| BACKGROUND_OBJECT_NUMBER [static] | int | r | 背景对象编号 |
| args | IMaskingArgs | r/w | 获取或设置分割算法的参数。 |
| background_replacement_color | Color | r/w | 获取或设置背景替换颜色。 |
| 分解 | bool | r/w | 获取或设置一个值,指示是否 不需要将遮罩中的每个形状分离为单独的对象,或将其作为从遮罩中分离的与背景分开的统一对象。 |
| export_options | ImageOptionsBase | r/w | 获取或设置图像导出选项。 |
| feathering_radius | int | r/w | 获取或设置羽化半径。 |
| masking_area | Rectangle | r/w | 获取或设置遮罩区域。 |
| method | SegmentationMethod | r/w | 获取或设置分割方法。 |
Constructor: GraphCutMaskingOptions()
GraphCutMaskingOptions()
初始化 GraphCutMaskingOptions 类的新实例
Property: feathering_radius
获取或设置羽化半径。
See also:
Example # 1: Saving Graph Cut image masking result with feathering set to 3. Image masking…
Examples
Saving Graph Cut image masking result with feathering set to 3. Image masking is performed using specified Point array.
import aspose.pycore as aspycore
from aspose.imaging import Image, Color, RasterImage
from aspose.imaging.masking.options import AutoMaskingArgs, GraphCutMaskingOptions, SegmentationMethod
from aspose.imaging.sources import FileCreateSource
from aspose.imaging.imageoptions import PngOptions
from aspose.imaging.fileformats.png import PngColorType
with aspycore.as_of(Image.load("input.jpg"), RasterImage) as image:
obj_init = PngOptions()
obj_init.color_type = PngColorType.TRUECOLOR_WITH_ALPHA
obj_init.source = FileCreateSource("tempFile")
obj_init2 = AutoMaskingArgs()
obj_init2.objects_points = [[Point(100, 100)]]
options = GraphCutMaskingOptions()
options.feathering_radius = 3
options.method = SegmentationMethod.GRAPH_CUT
options.decompose = False
options.export_options = obj_init
options.background_replacement_color = Color.transparent
options.args = obj_init2
results = ImageMasking(image).decompose(options)
with aspycore.as_of(results[1].get_image(), RasterImage) as result_image:
obj_init4 = PngOptions()
obj_init4.color_type = PngColorType.TRUECOLOR_WITH_ALPHA
result_image.save("output.png", obj_init4)
# 释放所有子图像
for it in results:
with it as _:
pass