StrataQuest Home StrataQuest Glossary Top-hat transform
Image Processing & Correction

Top-hat transform

Subtract the smoothed image from the original; what's left is the small bright stuff

Definition
The top-hat transform is defined as: top-hat(image) = image − opening(image, structuring_element). The openingLoading... smooths out features smaller than the structuring element while preserving larger structures and the background. Subtracting this smoothed version from the original cancels the background and leaves the small bright features — exactly what the opening removed. The structuring element size sets the scale: anything brighter than its surroundings and smaller than the element survives the subtraction; everything else cancels. The complement, sometimes called bottom-hat, is closing(image) − image and isolates small dark features by the same logic.
Background separation by morphology
The opening is a slow-varying estimate; subtracting it isolates the fast-varying foreground
Structuring element size sets the scale of detection
Bigger element, larger features survive in the result
Bright features only — use bottom-hat for dark ones
The transform is asymmetric
Where it sits in a pipeline
Pre-Processing, before thresholding

When top-hat earns its place

The cleanest application is fluorescence imaging where the field of view has a brightness gradient — illumination variation, broad autofluorescence, or any background that varies on a much larger scale than the cells you want to detect. The cells are bright spots; the background is the slowly-varying canvas underneath. Top-hat separates the two cleanly.

Use a structuring element a few cell-diameters wide. The cells (small, bright) survive the subtraction; the gradient (large, slow) is captured in the opening and removed. A single thresholdLoading... on the top-hat result then operates on a flat baseline, and the same threshold works across the whole field.

The same logic applies in brightfield imaging when small dark features (dots, granules) sit on a varying brightfield canvas — there, the symmetric tool, bottom-hat, separates them in the same way.

Share This Term
Term Connections