= Foreground-background polarity
\b[Foreground-background polarity] specifies which of two image classes is treated as the selected structure and which as its background. It involves a numerical convention as well as the intended interpretation: high-valued pixels can represent foreground in one encoding, while a dark feature may require the opposite threshold direction. A <binary image>'s appearance alone does not establish its polarity.
For a chosen intensity threshold $T$, define complementary normalized masks
$$
M^{+}_{ij}=\mathbf1\{I_{ij}>T\},
\qquad
M^{-}_{ij}=1-M^{+}_{ij}=\mathbf1\{I_{ij}\leq T\}.
$$
The second is the <complement of a set> within the declared pixel grid. For the stipulated row $I=(20,80,120,200)$ and $T=120$, the two <binary selection masks> are $(0,0,0,1)$ and $(1,1,1,0)$. Equality belongs to the second selection. OpenCV's `THRESH_BINARY` and `THRESH_BINARY_INV` use these respective comparison directions, with the chosen output maximum replacing 1.<Image Thresholding in the OpenCV documentation>[OpenCV4.13.0, Simple Thresholding; linked ThresholdTypes reference, THRESH_BINARY and THRESH_BINARY_INV]{ref}
An <image lookup table> is a separate mapping from stored values to displayed colors. <ImageJ>'s Create Mask command writes 255 inside a selection and 0 outside, but its default inverting lookup table can display the selected 255-valued pixels as black.<ImageJ User Guide by Tiago Ferreira and Wayne Rasband>[IJ1.46r, section27.12.10, Create Mask, stored values and inverting LUT]{ref} Reversing that display mapping does not exchange the stored pixel values.
The distinction has a direct computational consequence. In its binary-image input, the documented <Sholl analysis> implementation treats zero intensities as background regardless of the lookup table or Black Background option.<Sholl Analysis in the SNT documentation>[Cf. Segmentation, zero-intensity convention]{ref} A visually inverted display can therefore leave the selected numerical structure unchanged, whereas replacing an 8-bit mask $B$ by $255-B$ exchanges its zero and 255 classes.
A reproducible geometric measurement records the threshold comparison, the values assigned to selected and excluded pixels, and any display-only inversion. A <region of interest> can further restrict the grid over which a complement is intended; reversing a mask over the whole image is different from selecting its complement only inside that region.
Back to article page