Foreground-background polarity 2026-11-05
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 , define complementary normalized masksThe second is the complement of a set within the declared pixel grid. For the stipulated row and , the two binary selection masks are and . 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.[ref]Image Thresholding in the OpenCV documentation. OpenCV4.13.0, Simple Thresholding; linked ThresholdTypes reference, THRESH_BINARY and THRESH_BINARY_INV
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.[ref]
ImageJ User Guide by Tiago Ferreira and Wayne Rasband. IJ1.46r, section27.12.10, Create Mask, stored values and inverting LUT
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.[ref]
Sholl Analysis in the SNT documentation. Cf. Segmentation, zero-intensity convention
A visually inverted display can therefore leave the selected numerical structure unchanged, whereas replacing an 8-bit mask by 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.
Pixel format 2026-11-05
A pixel format specifies how stored bits represent a pixel value: its components or table index, the allocation of bits to those components, and the applicable representation conventions. A complete image layout also needs dimensions and row organization, including framebuffer stride. The Linux frame-buffer API separates storage type from color interpretation and describes component offsets and lengths explicitly.[ref]
The Frame Buffer Device API in the Linux Kernel documentation. Sections2–4, types and visuals; bits_per_pixel and fb_bitfield offset/length
For an original packed pixel format, place red, green and blue codes in a 16-bit unsigned word , with widths 5, 6 and 5 bits respectively. Declare the red component to occupy bits15–11, green10–5 and blue4–0:These non-overlapping bit fields specify a particular encoding. Setting gives , or
0xF800 in hexadecimal. Knowing only “16 bits per pixel” would not identify those component positions.Endianness then controls how the word occupies byte-addressed computer memory. Little-endian storage of
0xF800 gives successive bytes 00 F8; big-endian storage gives F8 00. Reading the little-endian bytes as a big-endian word instead produces 0x00F8. Under the same declared component fields, that decodes to rather than . Bit significance in the word and byte order in memory are separate specifications.Bit allocation also limits representable component codes: the red and blue fields have 32 levels each, while green has 64. If normalized codes are defined as , and , their respective increments are , and . These are code increments, not a claim that emitted light varies linearly with the stored number. The RGB color model and an appropriate color space supply further interpretation.
Other formats can store an image lookup table index or include an alpha channel for transparency. The frame-buffer documentation likewise distinguishes pseudocolor indices from direct component fields.[ref]
The Frame Buffer Device API in the Linux Kernel documentation. Section2, FB_VISUAL_PSEUDOCOLOR and component-based visuals; section4, transparency and colorspace fields
Report the actual format alongside dimensions and stride when exchanging pixel buffers.