Class GraphCutMaskingOptions
이름 공간 : Aspose.Imaging.Masking.Options 모임: Aspose.Imaging.dll (25.4.0)
GraphCut 자동 마스크 옵션.
public class GraphCutMaskingOptions : MaskingOptions
Inheritance
object ← MaskingOptions ← GraphCutMaskingOptions
Derived
상속 회원들
MaskingOptions.BackgroundObjectNumber , MaskingOptions.Method , MaskingOptions.Args , MaskingOptions.ExportOptions , MaskingOptions.MaskingArea , MaskingOptions.Decompose , MaskingOptions.BackgroundReplacementColor , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
이미지 크기에 기초한 페테레이션과 함께 이미지 마스크 결과를 저장합니다. 이미지 마스크는 자동으로 계산된 기본 충격을 사용하여 수행됩니다. AutoMaskingGraphCutOptions의 Args 속성은 기본 충격이 끝에 배치되기 때문에 무시될 수 있습니다.
MaskingResult[] results;
using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
{
AutoMaskingGraphCutOptions options = new AutoMaskingGraphCutOptions
{
CalculateDefaultStrokes = true,
FeatheringRadius = (Math.Max(image.Width, image.Height) / 500) + 1,
Method = SegmentationMethod.GraphCut,
Decompose = false,
ExportOptions =
new PngOptions()
{
ColorType = PngColorType.TruecolorWithAlpha,
Source = new FileCreateSource("tempFile")
},
BackgroundReplacementColor = Color.Transparent
};
results = new ImageMasking(image).Decompose(options);
}
using (RasterImage resultImage = (RasterImage)results[1].GetImage())
{
resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}
이미지 마스크 결과를 저장하여 이미지 크기에 기초한 페테레이션으로. 이미지 마스크는 자동으로 계산된 기본 충격을 사용하여 수행됩니다. 또한 두 개의 가정된 개체의 데이터는 AutoMaskingGraphCutOptions의 AssumedObjects 속성에서도 지정됩니다.
List<assumedobjectdata> assumedObjects = new List<assumedobjectdata>();
assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Human, new Rectangle(100, 100, 150, 300)));
assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Dog, new Rectangle(300, 100, 50, 30)));
MaskingResult[] results;
using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
{
AutoMaskingGraphCutOptions options = new AutoMaskingGraphCutOptions
{
AssumedObjects = assumedObjects,
CalculateDefaultStrokes = true,
FeatheringRadius = (Math.Max(image.Width, image.Height) / 500) + 1,
Method = SegmentationMethod.GraphCut,
Decompose = false,
ExportOptions =
new PngOptions()
{
ColorType = PngColorType.TruecolorWithAlpha,
Source = new FileCreateSource("tempFile")
},
BackgroundReplacementColor = Color.Transparent
};
results = new ImageMasking(image).Decompose(options);
}
using (RasterImage resultImage = (RasterImage)results[1].GetImage())
{
resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}</assumedobjectdata></assumedobjectdata>
Graph Cut 이미지 마스크 결과를 저장하여 페이더링 세트에서 3. 이미지 마스크는 지정된 포인트 라인을 사용하여 수행됩니다.
MaskingResult[] results;
using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
{
GraphCutMaskingOptions options = new GraphCutMaskingOptions()
{
FeatheringRadius = 3,
Method = SegmentationMethod.GraphCut,
Decompose = false,
ExportOptions =
new PngOptions()
{
ColorType = PngColorType.TruecolorWithAlpha,
Source = new FileCreateSource("tempFile")
},
BackgroundReplacementColor = Color.Transparent,
Args = new AutoMaskingArgs()
{
ObjectsPoints = new Point[][]
{
new Point[]
{
new Point(100, 100),
},
}
}
};
results = new ImageMasking(image).Decompose(options);
}
using (RasterImage resultImage = (RasterImage)results[1].GetImage())
{
resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}
이미지 마스크 결과는 이미지 크기에 기초한 마스크와 새 마스크 이테라션을위한 마스크 옵션을 다시 사용합니다. 이미지 마스크는 자동으로 계산 된 기본 마스크를 사용하여 수행됩니다. 또한 두 개의 가정된 개체의 데이터는 또한 AutoMaskingGraphCutOptions의 AssumedObjects 속성에 지정됩니다. 초기 마스크 결과를 얻은 후에, 적용 된 배경 / 전구 마스크가 수정되고 또 다른 마스크 이테라션이 수행됩니다.
List<assumedobjectdata> assumedObjects = new List<assumedobjectdata>();
assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Human, new Rectangle(100, 100, 150, 300)));
assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Dog, new Rectangle(300, 100, 50, 30)));
MaskingResult[] results;
AutoMaskingGraphCutOptions options;
using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
{
options = new AutoMaskingGraphCutOptions
{
AssumedObjects = assumedObjects,
CalculateDefaultStrokes = true,
FeatheringRadius = 3,
Method = SegmentationMethod.GraphCut,
Decompose = false,
ExportOptions =
new PngOptions()
{
ColorType = PngColorType.TruecolorWithAlpha,
Source = new FileCreateSource("tempFile")
},
BackgroundReplacementColor = Color.Transparent
};
results = new ImageMasking(image).Decompose(options);
}
// At this point applied foreground/background strokes can be analyzed and based on it additional
// foreground/background strokes can be manually provided.
Point[] appliedBackgroundStrokes = options.DefaultBackgroundStrokes;
Point[] appliedForegroundStrokes = options.DefaultForegroundStrokes;
Rectangle[] appliedObjectRectangles = options.DefaultObjectsRectangles;
using (RasterImage resultImage = (RasterImage)results[1].GetImage())
{
resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}
using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
{
// Re-using AutoMaskingGraphCutOptions there is no need to perform default strokes calculations second time.
options.CalculateDefaultStrokes = false;
// When both default strokes and ObjectsPoints in the Args property of AutoMaskingArgs are provided, Point arrays are end up combined.
// The first ObjectsPoints array is considered to be a background points array and
// the second ObjectsPoints array is considered to be a foreground points array.
// When both DefaultObjectsRectangles and ObjectsRectangles in the Args property of AutoMaskingArgs are provided,
// only the array from the Args is being used.
options.Args = new AutoMaskingArgs()
{
ObjectsPoints = new Point[][]
{
new Point[] { new Point(100, 100), new Point(150, 100) },
new Point[] { new Point(500, 200) },
},
ObjectsRectangles = new Rectangle[]
{
new Rectangle(100, 100, 300, 300),
}
};
results = new ImageMasking(image).Decompose(options);
}
using (RasterImage resultImage = (RasterImage)results[1].GetImage())
{
resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}</assumedobjectdata></assumedobjectdata>
이미지 크기에 기초한 마스크 결과를 저장하고, 얻은 기본 충격을 수정하고 새로운 마스크 이테라션을 위해 사용합니다. 이미지 마스크는 자동으로 계산 된 기본 충격을 사용하여 수행됩니다. 또한 두 개의 가정된 개체의 데이터는 또한 AutoMaskingGraphCutOptions의 AssumedObjects 속성에 지정됩니다. 초기 마스크 결과를 얻은 후에, 적용 된 배경 / 전구 충격을 수정하고 새로운 GraphCutMaskingOptions를 사용하여 또 다른 마스크 이테라션이 수행됩니다.
List<assumedobjectdata> assumedObjects = new List<assumedobjectdata>();
assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Human, new Rectangle(100, 100, 150, 300)));
assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Dog, new Rectangle(300, 100, 50, 30)));
MaskingResult[] results;
AutoMaskingGraphCutOptions options;
using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
{
options = new AutoMaskingGraphCutOptions
{
AssumedObjects = assumedObjects,
CalculateDefaultStrokes = true,
FeatheringRadius = 3,
Method = SegmentationMethod.GraphCut,
Decompose = false,
ExportOptions =
new PngOptions()
{
ColorType = PngColorType.TruecolorWithAlpha,
Source = new FileCreateSource("tempFile")
},
BackgroundReplacementColor = Color.Transparent
};
results = new ImageMasking(image).Decompose(options);
}
// At this point applied foreground/background strokes can be analyzed and based on it additional
// foreground/background strokes can be manually provided.
Point[] appliedBackgroundStrokes = options.DefaultBackgroundStrokes;
Point[] appliedForegroundStrokes = options.DefaultForegroundStrokes;
Rectangle[] appliedObjectRectangles = options.DefaultObjectsRectangles;
using (RasterImage resultImage = (RasterImage)results[1].GetImage())
{
resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}
appliedBackgroundStrokes[5] = new Point(100, 100);
appliedBackgroundStrokes[15] = new Point(150, 100);
appliedForegroundStrokes[1] = new Point(500, 200);
appliedObjectRectangles[0] = new Rectangle(100, 100, 300, 300);
using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
{
GraphCutMaskingOptions graphCutOptions = new GraphCutMaskingOptions()
{
FeatheringRadius = 3,
Method = SegmentationMethod.GraphCut,
Decompose = false,
ExportOptions = new PngOptions()
{
ColorType = PngColorType.TruecolorWithAlpha,
Source = new FileCreateSource("tempFile")
},
BackgroundReplacementColor = Color.Transparent,
Args = new AutoMaskingArgs()
{
ObjectsPoints = new Point[][]
{
appliedBackgroundStrokes,
appliedForegroundStrokes
},
ObjectsRectangles = appliedObjectRectangles
}
};
results = new ImageMasking(image).Decompose(graphCutOptions);
}
using (RasterImage resultImage = (RasterImage)results[1].GetImage())
{
resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}</assumedobjectdata></assumedobjectdata>
Constructors
GraphCutMaskingOptions()
public GraphCutMaskingOptions()
Properties
FeatheringRadius
빛을 얻거나 빛의 방사선을 설정합니다.
public int FeatheringRadius { get; set; }
부동산 가치
Examples
이미지 크기에 기초한 페테레이션과 함께 이미지 마스크 결과를 저장합니다. 이미지 마스크는 자동으로 계산된 기본 충격을 사용하여 수행됩니다. AutoMaskingGraphCutOptions의 Args 속성은 기본 충격이 끝에 배치되기 때문에 무시될 수 있습니다.
MaskingResult[] results;
using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
{
AutoMaskingGraphCutOptions options = new AutoMaskingGraphCutOptions
{
CalculateDefaultStrokes = true,
FeatheringRadius = (Math.Max(image.Width, image.Height) / 500) + 1,
Method = SegmentationMethod.GraphCut,
Decompose = false,
ExportOptions =
new PngOptions()
{
ColorType = PngColorType.TruecolorWithAlpha,
Source = new FileCreateSource("tempFile")
},
BackgroundReplacementColor = Color.Transparent
};
results = new ImageMasking(image).Decompose(options);
}
using (RasterImage resultImage = (RasterImage)results[1].GetImage())
{
resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}
이미지 마스크 결과를 저장하여 이미지 크기에 기초한 페테레이션으로. 이미지 마스크는 자동으로 계산된 기본 충격을 사용하여 수행됩니다. 또한 두 개의 가정된 개체의 데이터는 AutoMaskingGraphCutOptions의 AssumedObjects 속성에서도 지정됩니다.
List<assumedobjectdata> assumedObjects = new List<assumedobjectdata>();
assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Human, new Rectangle(100, 100, 150, 300)));
assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Dog, new Rectangle(300, 100, 50, 30)));
MaskingResult[] results;
using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
{
AutoMaskingGraphCutOptions options = new AutoMaskingGraphCutOptions
{
AssumedObjects = assumedObjects,
CalculateDefaultStrokes = true,
FeatheringRadius = (Math.Max(image.Width, image.Height) / 500) + 1,
Method = SegmentationMethod.GraphCut,
Decompose = false,
ExportOptions =
new PngOptions()
{
ColorType = PngColorType.TruecolorWithAlpha,
Source = new FileCreateSource("tempFile")
},
BackgroundReplacementColor = Color.Transparent
};
results = new ImageMasking(image).Decompose(options);
}
using (RasterImage resultImage = (RasterImage)results[1].GetImage())
{
resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}</assumedobjectdata></assumedobjectdata>
Graph Cut 이미지 마스크 결과를 저장하여 페이더링 세트에서 3. 이미지 마스크는 지정된 포인트 라인을 사용하여 수행됩니다.
MaskingResult[] results;
using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
{
GraphCutMaskingOptions options = new GraphCutMaskingOptions()
{
FeatheringRadius = 3,
Method = SegmentationMethod.GraphCut,
Decompose = false,
ExportOptions =
new PngOptions()
{
ColorType = PngColorType.TruecolorWithAlpha,
Source = new FileCreateSource("tempFile")
},
BackgroundReplacementColor = Color.Transparent,
Args = new AutoMaskingArgs()
{
ObjectsPoints = new Point[][]
{
new Point[]
{
new Point(100, 100),
},
}
}
};
results = new ImageMasking(image).Decompose(options);
}
using (RasterImage resultImage = (RasterImage)results[1].GetImage())
{
resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}
이미지 마스크 결과는 이미지 크기에 기초한 마스크와 새 마스크 이테라션을위한 마스크 옵션을 다시 사용합니다. 이미지 마스크는 자동으로 계산 된 기본 마스크를 사용하여 수행됩니다. 또한 두 개의 가정된 개체의 데이터는 또한 AutoMaskingGraphCutOptions의 AssumedObjects 속성에 지정됩니다. 초기 마스크 결과를 얻은 후에, 적용 된 배경 / 전구 마스크가 수정되고 또 다른 마스크 이테라션이 수행됩니다.
List<assumedobjectdata> assumedObjects = new List<assumedobjectdata>();
assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Human, new Rectangle(100, 100, 150, 300)));
assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Dog, new Rectangle(300, 100, 50, 30)));
MaskingResult[] results;
AutoMaskingGraphCutOptions options;
using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
{
options = new AutoMaskingGraphCutOptions
{
AssumedObjects = assumedObjects,
CalculateDefaultStrokes = true,
FeatheringRadius = 3,
Method = SegmentationMethod.GraphCut,
Decompose = false,
ExportOptions =
new PngOptions()
{
ColorType = PngColorType.TruecolorWithAlpha,
Source = new FileCreateSource("tempFile")
},
BackgroundReplacementColor = Color.Transparent
};
results = new ImageMasking(image).Decompose(options);
}
// At this point applied foreground/background strokes can be analyzed and based on it additional
// foreground/background strokes can be manually provided.
Point[] appliedBackgroundStrokes = options.DefaultBackgroundStrokes;
Point[] appliedForegroundStrokes = options.DefaultForegroundStrokes;
Rectangle[] appliedObjectRectangles = options.DefaultObjectsRectangles;
using (RasterImage resultImage = (RasterImage)results[1].GetImage())
{
resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}
using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
{
// Re-using AutoMaskingGraphCutOptions there is no need to perform default strokes calculations second time.
options.CalculateDefaultStrokes = false;
// When both default strokes and ObjectsPoints in the Args property of AutoMaskingArgs are provided, Point arrays are end up combined.
// The first ObjectsPoints array is considered to be a background points array and
// the second ObjectsPoints array is considered to be a foreground points array.
// When both DefaultObjectsRectangles and ObjectsRectangles in the Args property of AutoMaskingArgs are provided,
// only the array from the Args is being used.
options.Args = new AutoMaskingArgs()
{
ObjectsPoints = new Point[][]
{
new Point[] { new Point(100, 100), new Point(150, 100) },
new Point[] { new Point(500, 200) },
},
ObjectsRectangles = new Rectangle[]
{
new Rectangle(100, 100, 300, 300),
}
};
results = new ImageMasking(image).Decompose(options);
}
using (RasterImage resultImage = (RasterImage)results[1].GetImage())
{
resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}</assumedobjectdata></assumedobjectdata>
이미지 크기에 기초한 마스크 결과를 저장하고, 얻은 기본 충격을 수정하고 새로운 마스크 이테라션을 위해 사용합니다. 이미지 마스크는 자동으로 계산 된 기본 충격을 사용하여 수행됩니다. 또한 두 개의 가정된 개체의 데이터는 또한 AutoMaskingGraphCutOptions의 AssumedObjects 속성에 지정됩니다. 초기 마스크 결과를 얻은 후에, 적용 된 배경 / 전구 충격을 수정하고 새로운 GraphCutMaskingOptions를 사용하여 또 다른 마스크 이테라션이 수행됩니다.
List<assumedobjectdata> assumedObjects = new List<assumedobjectdata>();
assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Human, new Rectangle(100, 100, 150, 300)));
assumedObjects.Add(new AssumedObjectData(DetectedObjectType.Dog, new Rectangle(300, 100, 50, 30)));
MaskingResult[] results;
AutoMaskingGraphCutOptions options;
using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
{
options = new AutoMaskingGraphCutOptions
{
AssumedObjects = assumedObjects,
CalculateDefaultStrokes = true,
FeatheringRadius = 3,
Method = SegmentationMethod.GraphCut,
Decompose = false,
ExportOptions =
new PngOptions()
{
ColorType = PngColorType.TruecolorWithAlpha,
Source = new FileCreateSource("tempFile")
},
BackgroundReplacementColor = Color.Transparent
};
results = new ImageMasking(image).Decompose(options);
}
// At this point applied foreground/background strokes can be analyzed and based on it additional
// foreground/background strokes can be manually provided.
Point[] appliedBackgroundStrokes = options.DefaultBackgroundStrokes;
Point[] appliedForegroundStrokes = options.DefaultForegroundStrokes;
Rectangle[] appliedObjectRectangles = options.DefaultObjectsRectangles;
using (RasterImage resultImage = (RasterImage)results[1].GetImage())
{
resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}
appliedBackgroundStrokes[5] = new Point(100, 100);
appliedBackgroundStrokes[15] = new Point(150, 100);
appliedForegroundStrokes[1] = new Point(500, 200);
appliedObjectRectangles[0] = new Rectangle(100, 100, 300, 300);
using (RasterImage image = (RasterImage)Image.Load("input.jpg"))
{
GraphCutMaskingOptions graphCutOptions = new GraphCutMaskingOptions()
{
FeatheringRadius = 3,
Method = SegmentationMethod.GraphCut,
Decompose = false,
ExportOptions = new PngOptions()
{
ColorType = PngColorType.TruecolorWithAlpha,
Source = new FileCreateSource("tempFile")
},
BackgroundReplacementColor = Color.Transparent,
Args = new AutoMaskingArgs()
{
ObjectsPoints = new Point[][]
{
appliedBackgroundStrokes,
appliedForegroundStrokes
},
ObjectsRectangles = appliedObjectRectangles
}
};
results = new ImageMasking(image).Decompose(graphCutOptions);
}
using (RasterImage resultImage = (RasterImage)results[1].GetImage())
{
resultImage.Save("output.png", new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}</assumedobjectdata></assumedobjectdata>