How To: Enhance Low-Contrast Images#
When colonies are faint or the agar background is uneven, detection suffers. Use CLAHE, ContrastStretching, or HomomorphicFilter to boost local contrast in detect_mat before detection.
[1]:
from phenotypic.data import load_yeast_plate
from phenotypic.enhance import CLAHE, ContrastStretching, HomomorphicFilter
[2]:
plate = load_yeast_plate()
plate.detect_mat.dash()
Data type cannot be displayed: application/vnd.plotly.v1+json
Option 1: CLAHE#
Adaptive histogram equalization that boosts local contrast. Best for plates with locally varying brightness.
[3]:
enhanced = CLAHE(clip_limit=0.02).apply(plate.copy())
enhanced.detect_mat.dash()
Data type cannot be displayed: application/vnd.plotly.v1+json
Option 2: Contrast Stretching#
Linearly maps the intensity range to fill the full dynamic range. Simple and effective when the histogram is narrow but unimodal.
[4]:
enhanced2 = ContrastStretching().apply(plate.copy())
enhanced2.detect_mat.dash()
Data type cannot be displayed: application/vnd.plotly.v1+json
Option 3: Homomorphic Filter#
Separates illumination from reflectance in the frequency domain. Best for correcting uneven illumination gradients across the plate.
[5]:
enhanced3 = HomomorphicFilter(sigma=200.0, gamma_low=0.5, gamma_high=1.5).apply(plate.copy())
enhanced3.detect_mat.dash()
Data type cannot be displayed: application/vnd.plotly.v1+json
Choose based on the root cause: CLAHE for general low contrast, ContrastStretching for narrow histograms, HomomorphicFilter for uneven illumination.