ScientiaLux
strataquest Glossary Post Processing
BOM Group

Post Processing

Cleanup operations for refining segmentation results

View
Definition
The refinement stage after initial segmentation — morphological operations that clean up binary masks, fill interior gaps, remove noise-generated fragments, and smooth irregular boundaries before labeling and measurement. Post-processing bridges the gap between raw thresholding output and the clean, accurate object masks needed for quantitative analysis in StrataQuest.
Fill Holes Preserves Object Integrity
Closes interior gaps that would split measurements
Remove Small Objects Eliminates Noise
Minimum area threshold filters noise-generated fragments
Morphological Boundary Smoothing
Opening + closing regularizes jagged edges
Processing Order Matters
Fill holes before removing small objects for best results

Operations Reference

OperationInputDescription
Smooth boundariesBinary imageApplies morphological opening (remove protrusions) followed by closing (fill gaps) to produce smooth, regular object boundaries. SE size determines the smoothness scale.
Fill holesBinary imageIdentifies enclosed background regions within foreground objects and fills them. Uses flood-fill from the image border — any background pixel not reachable from the border is inside an object.
Remove small objectsBinary image + min areaPerforms connected-component labeling internally, removes components smaller than the specified area threshold, and returns the cleaned binary mask.
Simplified

Smooth boundaries uses opening+closing to remove jagged edges. Fill holes fills enclosed gaps inside objects. Remove small objects eliminates tiny noise artifacts below a size threshold. Apply these before labeling to get clean, accurate objects.

Image Processing Foundation

Post-processing transforms raw segmentation output into clean, measurement-ready object masks. The operations are rooted in mathematical morphology — a framework for analyzing and modifying shape using a small probe called a structuring element (SE) — and connected-component analysis for identifying and filtering individual objects (Gonzalez & Woods, §9.5–9.6).

Morphological Clean-Up

Erosion removes boundary pixels: the SE is placed at each pixel, and only pixels where the SE fits entirely within the foreground survive. Solomon & Breckon use the "prairie-fire" analogy — imagine setting fire to the boundary; the fire advances inward, consuming pixels layer by layer. Dilation adds boundary pixels: the SE is placed at each background pixel adjacent to the foreground, and all pixels it touches become foreground — the boundary grows outward.

Combining these yields compound operations: Opening (erosion followed by dilation) removes small protrusions and isolated noise pixels without significantly changing object size. Closing (dilation followed by erosion) fills small gaps and holes while preserving overall dimensions. The Smooth Boundaries operation applies opening then closing in sequence, producing regularized contours. The SE size controls the scale of features affected — a 3×3 SE smooths pixel-level noise; a larger SE smooths larger irregularities but risks merging nearby objects.

Distance Transforms & Watershed

For separating touching objects (not a BOM post-processing operation, but closely related in the pipeline), the Euclidean Distance Transform (EDT) computes each foreground pixel's minimum distance to the nearest background pixel. Local maxima of the distance map identify the centers of well-separated objects — these become seed points. The watershed algorithm then "floods" from these seeds: imagine the distance map as a topographic surface and water rising from each seed — where two flood regions meet, a watershed boundary is placed, segmenting touching objects. Over-segmentation (too many false boundaries) is a common failure; marker-controlled watershed mitigates this by restricting seeds to verified markers (Gonzalez & Woods, §10.5).

Connected Component Analysis

Connected-component labeling identifies distinct foreground regions by scanning the image and assigning unique integer labels to contiguous pixel groups. 4-connectivity considers only orthogonal neighbors (N/S/E/W); 8-connectivity includes diagonals — the choice affects whether diagonally-touching pixels are labeled as one or two objects. Once labeled, components can be filtered by properties: area filtering removes components below a pixel-count threshold (the Remove Small Objects operation); shape filtering can select components by circularity, aspect ratio, or other geometric criteria.

Pipeline Ordering

The order of post-processing operations matters because each step changes the input to the next. The recommended sequence — (1) Smooth boundaries → (2) Fill holes → (3) Remove small objects → (4) Label — maximizes cleanup effectiveness: smoothing may resolve some holes, filling may increase component sizes above the removal threshold, and final removal catches remaining artifacts before labeling. Reversing the order causes failures: removing small objects before filling holes can delete valid object fragments that would have grown above threshold after hole-filling. Similarly, labeling before cleanup creates spurious events that persist in downstream analysis even if the underlying mask is later corrected.

Simplified

Post-processing cleans up the messy output of thresholding. Erosion shrinks objects (like a fire burning inward from edges), dilation grows them, and combining both in sequence (opening then closing) smooths boundaries without changing overall size. Fill holes closes interior gaps from uneven staining. Remove small objects eliminates noise fragments below a minimum size. The order matters: smooth first, fill holes second, remove small objects third, label last — each step makes the next one more effective.

When to Use Which

Smooth Boundaries

Use after thresholding when object edges are jagged or pixelated. The SE size should be small enough not to significantly change object dimensions — typically 1–3 pixels for nuclear-scale objects. Over-smoothing can merge nearby objects or remove thin structures.

Fill Holes

Use when thresholding misses interior regions of objects — common with heterogeneous staining where some areas within a nucleus or tissue region are below threshold. Filling ensures area measurements reflect the true object extent.

Remove Small Objects

Use to eliminate noise-induced artifacts. Set the minimum area based on the smallest real object in your image. For nuclear detection, objects below ~10 pixels are almost certainly noise. For tissue area detection, the threshold may be much larger (hundreds of pixels).

Processing Order

Recommended sequence: (1) Smooth boundaries, (2) Fill holes, (3) Remove small objects, (4) Label. This order maximizes cleanup effectiveness: smoothing may resolve some holes, filling may increase sizes above the removal threshold, and final removal catches any remaining artifacts before labeling.

Simplified

Apply in order: Smooth first (fix edges), then Fill (close holes), then Remove (eliminate small noise), then Label (create coded image). Each step cleans up issues that make the next step more effective.

Connected Terms

Share This Term
Term Connections