Understand each step, tune parameters, and validate results.
DAPI images typically have a dark background and bright nuclei. The pipeline enhances contrast, removes illumination, binarizes, fills nuclei, and splits touching objects before filtering by size/shape. Each step below lists the output, its purpose, and the parameters that control it.
Single-channel intensity for DAPI (max of blue and grayscale).
Controls: —
Expected: dark background with brighter oval nuclei; not binary.
Contrast Limited Adaptive Histogram Equalization (CLAHE) to boost local contrast.
claheClip
: contrast strength (e.g., 1.5–2.5).claheTile
: tile size (6–12). Smaller → more local enhancement.Expected: nuclei appear brighter and sharper; background remains dark; mild halos are acceptable.
Median blur of enhanced to estimate slow-varying illumination; later subtracted.
bgKernel
(odd): increase until nuclei texture largely disappears here (31–61).Expected: very smooth, blurry image with illumination only; nuclei details mostly gone.
enhanced − background, so nuclei are bright on near-black background.
Controls: inherits clahe*
and bgKernel
. If rings appear, raise bgKernel
.
Expected: bright solid-looking blobs; background near zero; minimal rings.
Gaussian blur to suppress small noise prior to thresholding.
gaussKernel
(odd): 3–5. Too large merges neighbors.Expected: slightly smoother version of normalized; small speckles reduced.
Global threshold baseline (Otsu). Should produce solid-ish blobs where contrast is strong.
Expected: binary; most bright nuclei white, background black; may miss dim nuclei.
Local thresholding for uneven illumination.
adaptiveBlock
(odd): 31–51 neighborhood size.adaptiveC
: bias; raise to suppress edge-only rims (5–10).Expected: binary; captures dimmer nuclei with thicker blobs; occasional ring edges may appear if parameters are low.
Threshold at a percentile of blurred intensity (keeps only bright cores).
brightPercentile
: 60–90 (85–90 suppresses thin edges).Expected: sparse binary showing only bright cores; small white spots centered in nuclei.
Union of the three thresholds above; foreground should be white nuclei on black background.
invertAuto
: auto-invert if foreground ratio is extremely high; disable if background turns white.Expected: binary with white blobs for each nucleus; background black; not dominated by thin rings.
Morphological close + flood-fill to convert rings to solid blobs.
openKernel
: denoise small specks.closeKernel
, closeIter
: bridge gaps and fill interiors.Expected: binary; nuclei are solid white (holes filled) with smooth edges; neighboring nuclei may still touch.
Distance-transform markers and watershed to separate touching nuclei.
distThresh
: fraction of max distance for peaks (0.35–0.55). Lower → more splits.Expected: colored label map with one color per nucleus; touching clusters separated without over-fragmentation.
Removes debris and overly large merged objects.
minArea
/ maxArea
(pixels).Expected: final count removes tiny debris and very large merged blobs; overlay shows mostly elliptical nuclei.
claheClip 2.0, claheTile 8; bgKernel 41–51; gaussKernel 3; adaptiveBlock 31–41; adaptiveC 8–10; brightPercentile 85–90; openKernel 3; closeKernel 7–9; closeIter 2; distThresh 0.4–0.45; invertAuto off; minArea 80–120; maxArea 3000–5000.
Parameter | Purpose | Increasing value tends to… | Typical range / notes |
---|---|---|---|
claheClip | CLAHE contrast strength | Boost local contrast; may accentuate rims if too high | 1.5–2.5 |
claheTile | CLAHE tile size | Smaller tiles ⇒ more local enhancement; can create artifacts if too small | 6–12 |
bgKernel | Median kernel for illumination background | Remove broader background; too small ⇒ ring artifacts | 31–61 (odd) |
gaussKernel | Gaussian blur before thresholding | Reduce speckle; too large merges neighbors | 3–5 (odd) |
adaptiveBlock | Neighborhood for adaptive threshold | Thicker, more stable blobs; too small ⇒ rimmy rings | 31–51 (odd) |
adaptiveC | Bias in adaptive threshold | Suppresses thin edges; too high removes dim nuclei | 5–10 |
brightPercentile | Percentile core-threshold on blurred image | Keep only brighter cores; higher ⇒ fewer edge pixels | 60–90 (85–90 typical) |
invertAuto | Auto-invert if foreground ratio is too high | Fixes polarity automatically; disable if background turns white | on/off |
openKernel | Remove small specks (morphological open) | More denoising; too large erodes nuclei | 3–5 (odd) |
closeKernel | Bridge gaps/fill holes (morphological close) | Fills interiors; too large causes merging | 7–11 (odd) |
closeIter | Repetitions of closing | More filling/smoothing; too many merges neighbors | 1–3 |
distThresh | Peak threshold for watershed split | Lower ⇒ more aggressive splitting; higher ⇒ fewer splits | 0.35–0.55 |
minArea / maxArea | Size filtering of final contours | Raise minArea to drop debris; raise maxArea to allow bigger nuclei | min 60–150, max 3000–6000 (dataset-dependent) |
scale | Pixel/μm for density only | Does not affect detection; only density calculation | Provided by user |
bgKernel
until normalized shows bright blobs (not rings).adaptiveBlock
/adaptiveC
to thicken thresh_adaptive blobs.brightPercentile
to suppress rim-only pixels.invertAuto
if background turns white.closeKernel
/closeIter
to fill interiors, then adjust distThresh
for splitting.minArea
/ maxArea
.bgKernel
.adaptiveBlock
and adaptiveC
.invertAuto
.closeKernel
/ closeIter
.distThresh
slightly (e.g., 0.45).minArea
/ maxArea
.