# What Enhancement Actually Does Enhancers modify the `detect_mat` accessor — the grayscale representation that detectors consume. They never touch `rgb` or `gray`, preserving the original image data for visualization and color measurements. ## Why Enhance? Raw plate images often have properties that confuse detectors: - **Noise** — random pixel variation that creates false positives - **Low contrast** — faint colonies barely distinguishable from agar - **Uneven illumination** — brightness gradients across the plate - **Texture** — agar surface patterns that mimic colony edges Enhancement addresses these problems by transforming `detect_mat` into a version where colonies stand out more clearly. ## Categories of Enhancement ### Smoothing (Noise Reduction) Reduce random variation while preserving colony boundaries. - **GaussianBlur** — isotropic smoothing; fast but blurs edges - **MedianFilter** — removes salt-and-pepper noise; preserves edges better - **BilateralDenoise** — smooths within regions; preserves edges explicitly - **StableDenoise (BM3D)** — state-of-the-art block-matching denoising ### Contrast Enhancement Increase the separation between colony and background intensities. - **CLAHE** — local adaptive histogram equalization; handles spatially varying contrast - **ContrastStretching** — linear remapping to fill the dynamic range - **UnsharpMask** — sharpens edges by subtracting a blurred version ### Illumination Correction Remove large-scale brightness gradients. - **HomomorphicFilter** — frequency-domain separation of illumination and reflectance - **SubtractGaussian** — subtracts a heavily blurred background estimate - **SubtractRollingBall** — morphological background estimation ### Structural Enhancement Enhance specific morphological features. - **FrangiVesselness** — enhances tubular structures (hyphae, branches) - **SobelFilter** — highlights edges - **PhaseCongruencyEnhancer** — illumination-invariant edge detection ## Stacking Enhancers Enhancers compose linearly — each reads `detect_mat`, modifies it, and writes it back. Order matters: 1. **Denoise first** — reduce noise before amplifying contrast 2. **Correct illumination** — normalize brightness before thresholding 3. **Enhance contrast** — maximize colony/background separation last A typical preprocessing chain: `GaussianBlur → HomomorphicFilter → CLAHE`. ## The Enhancement ↔ Detection Interface ``` detect_mat ──[Enhancer 1]──→ detect_mat ──[Enhancer 2]──→ detect_mat │ [Detector] │ objmask, objmap ``` This clean interface means you can swap any enhancer without affecting the detector, and vice versa. The pipeline model makes this experimentation easy.