Cell Counter – Processing Pipeline Help

Understand each step, tune parameters, and validate results.

Open App

Overview

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.

Step-by-step pipeline

1) gray

Single-channel intensity for DAPI (max of blue and grayscale).

Controls: —

Expected: dark background with brighter oval nuclei; not binary.

2) enhanced

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.

3) background

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.

4) normalized

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.

5) blurred

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.

6) thresh_otsu

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.

7) thresh_adaptive

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.

8) thresh_bright

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.

9) combined

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.

10) filled

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.

11) watershed split

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.

12) size filtering

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.

Recommended starting values (DAPI)

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 reference – what each control does

ParameterPurposeIncreasing value tends to…Typical range / notes
claheClipCLAHE contrast strengthBoost local contrast; may accentuate rims if too high1.5–2.5
claheTileCLAHE tile sizeSmaller tiles ⇒ more local enhancement; can create artifacts if too small6–12
bgKernelMedian kernel for illumination backgroundRemove broader background; too small ⇒ ring artifacts31–61 (odd)
gaussKernelGaussian blur before thresholdingReduce speckle; too large merges neighbors3–5 (odd)
adaptiveBlockNeighborhood for adaptive thresholdThicker, more stable blobs; too small ⇒ rimmy rings31–51 (odd)
adaptiveCBias in adaptive thresholdSuppresses thin edges; too high removes dim nuclei5–10
brightPercentilePercentile core-threshold on blurred imageKeep only brighter cores; higher ⇒ fewer edge pixels60–90 (85–90 typical)
invertAutoAuto-invert if foreground ratio is too highFixes polarity automatically; disable if background turns whiteon/off
openKernelRemove small specks (morphological open)More denoising; too large erodes nuclei3–5 (odd)
closeKernelBridge gaps/fill holes (morphological close)Fills interiors; too large causes merging7–11 (odd)
closeIterRepetitions of closingMore filling/smoothing; too many merges neighbors1–3
distThreshPeak threshold for watershed splitLower ⇒ more aggressive splitting; higher ⇒ fewer splits0.35–0.55
minArea / maxAreaSize filtering of final contoursRaise minArea to drop debris; raise maxArea to allow bigger nucleimin 60–150, max 3000–6000 (dataset-dependent)
scalePixel/μm for density onlyDoes not affect detection; only density calculationProvided by user

Tuning workflow

  1. Raise bgKernel until normalized shows bright blobs (not rings).
  2. Increase adaptiveBlock/adaptiveC to thicken thresh_adaptive blobs.
  3. Raise brightPercentile to suppress rim-only pixels.
  4. Ensure combined polarity is correct; disable invertAuto if background turns white.
  5. Use closeKernel/closeIter to fill interiors, then adjust distThresh for splitting.
  6. Finish with minArea / maxArea.

Troubleshooting by symptom

  • Rings in normalized: increase bgKernel.
  • Thin rims in thresh_adaptive: increase adaptiveBlock and adaptiveC.
  • Background white in combined: turn off invertAuto.
  • Holes in filled: increase closeKernel / closeIter.
  • Over-merged nuclei: raise distThresh slightly (e.g., 0.45).
  • Too many small/large rejections: adjust minArea / maxArea.