Method TryRemoveUniformBackground
TryRemoveUniformBackground(out ImageBuffer, byte, float)
Attempts to remove a UNIFORM background: the border color estimated by TryDetectBorderBackgroundColor(out Color32, float) is flood-filled from the image border and made fully transparent in a new RGBA32 copy. Only pixels CONNECTED to the border are removed, so an interior region that happens to share the background color (a white shirt on a white sweep, a highlight) keeps its opacity - this is the classic product-shot / logo / scan cutout, and it refuses honestly when the border is not uniform enough instead of guessing at a subject.
public bool TryRemoveUniformBackground(out ImageBuffer result, byte tolerance = 24, float minAccuracy = 0.85)
Parameters
resultImageBufferWhen the method returns
true, the RGBA32 cutout (background alpha 0). When the method returnsfalse,null- the source is unsuitable.tolerancebytePer-channel distance (0..255) a pixel may sit from the detected background color and still be filled. Defaults to
24.minAccuracyfloatThe border-uniformity bar forwarded to TryDetectBorderBackgroundColor(out Color32, float). Defaults to
0.85.
Returns
- bool
truewhen a cutout was produced; otherwisefalse.
Remarks
O(n) time, one pass of border-seeded flood fill over a byte visit map plus an explicit int stack - no recursion, no per-pixel allocations.
Exceptions
- ObjectDisposedException
Thrown if this instance has been disposed.