Remove dead code: unused detect_background_color and ForegroundEstimate extras
- chroma.detect_background_color had no callers anywhere (auto-detection goes through estimate_background_model / _background_border_cluster). - ForegroundEstimate.background and .correction were computed on every image but never consumed; only .rgb was used. estimate_foreground_rgb now returns the foreground array directly and the dataclass is gone, which also drops pymatting return_background work and a per-image correction-norm pass. Verified: CLI output on samples/TestImage3.png is byte-identical (SHA256) to the pre-cleanup baseline. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -112,22 +112,6 @@ def _background_border_cluster(
|
||||
return full, share, agree
|
||||
|
||||
|
||||
def detect_background_color(
|
||||
rgb: np.ndarray, settings: ChromaSettings | None = None
|
||||
) -> tuple[float, float, float]:
|
||||
"""Detect a single flat background colour from the image border.
|
||||
|
||||
Returns the colour as a 0..1 RGB triple. Raises RuntimeError (via
|
||||
:func:`_background_border_cluster`) if the border is not dominated by one flat
|
||||
colour, so callers fail loudly rather than matting against a wrong colour.
|
||||
Pure: reads pixels only, with no matting side effects.
|
||||
"""
|
||||
settings = settings or ChromaSettings()
|
||||
rgb_f, lab = convert_color_spaces(rgb)
|
||||
mask, _, _ = _background_border_cluster(lab, settings)
|
||||
return tuple(float(x) for x in np.median(rgb_f[mask], axis=0))
|
||||
|
||||
|
||||
def estimate_background_model(
|
||||
rgb: np.ndarray,
|
||||
settings: ChromaSettings,
|
||||
|
||||
Reference in New Issue
Block a user