StrataQuest Home StrataQuest Glossary Color space conversions
Image Processing & Correction

Color space conversions

Same colors, different coordinates — and the right coordinate system makes the analysis obvious

Definition
Color-space conversion engines remap an image between coordinate systems for color. RGB / BGR stores raw red/green/blue intensity per pixel — the native format of color cameras (BGR is the byte ordering some imaging libraries prefer; mathematically equivalent to RGB). HLS and HSV separate hue (color identity, where on the spectrum) from saturation (color purity) and from lightness or value (brightness) — useful when foreground has a distinctive color but variable brightness. Lab is a perceptually-uniform space — equal Euclidean distance corresponds to roughly equal perceived color difference, which makes color-similarity calculations correspond to what a human eye would judge. Optical Density (OD) is the Beer-LambertLoading... representation, linear with chromogen concentration in transmitted-light imaging — the right space for quantifying stain intensity. Grayscale drops color entirely, weighting the channels by perceptual luminance. Conversions are bidirectional except for grayscale (no information to invert).
Supporting
Pre processing - Basic - Virtual Channel
Video · Supporting
H&EDSPTCH
Video · Supporting
User Interface - Dimensions (8bit FL)
Video · Supporting
User Interface - Image Viewer + Toolbar
Video · Supporting
Dynamic range - 16bit to 8bit normalization
Video · Supporting
Same image, different coordinate systems
The pixel values change; the colors don't
HSV separates color identity from brightness
Hue stays constant under illumination changes
Lab is perceptually uniform
Equal distance ≈ equal perceived difference
Optical Density is linear with concentration
Beer-Lambert in coordinate form

Choosing the right space for the question

The choice of color space is rarely about display preference — it's about which coordinate axis aligns with the property the analysis is measuring. A few representative cases:

Segmenting one chromogen against another in IHC. Two chromogens (DAB brown, hematoxylin blue) absorb at different wavelengths, but their RGB representations interact — a darker DAB region looks similar in R/G/B to a lighter hematoxylin region. Color SeparationLoading... is the dedicated engine for this, but the conceptual move is to convert into a space where the chromogens separate cleanly: HSV by hue, or directly into per-stain optical-density channels.

Quantifying stain intensity for measurement. The native RGB pixel values aren't linear with stain concentration; the Beer-Lambert relationshipLoading... is exponential. Convert RGB to OD linearizes it. Subsequent measurements (mean, integrated density per cell) on the OD image quantify stain concentration directly, which is what the biology is asking about.

Color-based classification with variable lighting. A ClassifierLoading... trained on RGB features will struggle if the test images have different illumination than the training images — the same biology presents in different RGB values. Convert to HSV first; train and predict on hue and saturation, ignoring value (which carries the lighting variation). The classifier becomes lighting-invariant for free.

Computing color difference for distinguishing populations. If the analysis depends on "how different in color is this region from that one," Lab is the principled space to compute distances in. RGB distance can mislead — two pairs at the same RGB distance can look very different. Lab distance corresponds to perceived difference.

Reducing to grayscale for shape analysis. When color carries no information the analysis cares about — only structure does — Convert RGB to Grayscale drops a useless dimension. The grayscale result is the input to most filteringLoading... and labelingLoading... engines, which are designed for one-channel data.

Share This Term
Term Connections