StrataQuest Home › StrataQuest Glossary › Color Space Conversions
BOM Group

Color Space Conversions

Transforming between color representations

View
Definition
A camera stores each pixel as three intensities, blue, green and red, and in those numbers color and brightness are mixed together. These engines convert the pixel into another color space. HLS and HSV give hue its own channel, Lab spaces colors by how different they look, and grayscale keeps only a weighted brightness. Pick the space that gives your property its own axis.
Five target spaces
HLS, HSV, Lab, OD, and Grayscale
Hue ignores staining strength
Hue identifies stain type regardless of staining strength
Lab is perceptually uniform
Equal numerical distance = equal perceived difference
Grayscale is one-way
RGB → Gray loses color information permanently

Operations Reference

ConversionOutput ChannelsProperties
BGR ↔ HLSHue, Lightness, Saturation, in that channel order, stored as an 8-bit, 3-channel imageBidirectional: convert to HLS for analysis, back to BGR for visualization. Lightness is the average of the largest and smallest RGB channels. Saturation varies with lightness.
BGR ↔ HSVHue, Saturation, Value, in that channel order, stored as an 8-bit, 3-channel imageBidirectional, and the most common color conversion in image processing. Value is the largest RGB channel. More intuitive than HLS for image processing. Hue is undefined when S = 0 (gray pixels).
BGR ↔ LabL*, a* (green↔red), b* (blue↔yellow), stored as an 8-bit, 3-channel imageBidirectional, and the best choice for color comparison and perceptual analysis. Perceptually uniform. L* is close to perceived lightness; a* and b* encode color on orthogonal axes.
RGB → GrayscaleSingle intensity channelWeighted sum of the three channels, with weights you set (Weight - Blue, Weight - Green, Weight - Red; default 0.33 each). Non-invertible. For a perceptual gray, enter the NTSC luminance weights (0.299 R, 0.587 G, 0.114 B), which give green the most weight because human vision is most sensitive to green.
RGB ↔ ODOptical density, each of the three channels transformed independently, stored as an 8-bit, 3-channel imageBidirectional and lossless. Based on the Beer-Lambert law: it represents tissue thickness from the observed light.
Simplified

These conversions take raw camera RGB into spaces that separate color from brightness. In HSV, the most used, hue says which color, saturation how vivid and value how bright. Lab suits comparing colors, because equal distances mean equal visual differences. Grayscale keeps a single brightness channel.

When to Use Which

HSV for Stain Type Identification

In brightfield, chromogens have distinct hues: DAB brown, hematoxylin blue, Fast Red. Convert to HSV and threshold the hue channel, and you can separate stain types by color alone, whatever the staining intensity. For some applications this is a simpler alternative to full color deconvolution.

Lab for Color Distance

To decide whether two reference shades are the same chromogen, compare them in Lab, which gives the most meaningful distance. Two colors with ΔE (Euclidean distance in Lab) less than 2 are visually indistinguishable.

Grayscale for Single-Channel Processing

Many BOM operations, among them filtering, thresholding and morphology, need grayscale input. RGB to Grayscale makes one intensity channel as a weighted sum of the three channels, with weights you set. For quantitative IHC, use Color Separation or OD conversion instead: they give a channel per stain rather than a generic intensity average.

Histogram Equalization in HSV

In image processing generally, equalizing the R, G and B channels separately alters the hue. The usual approach is to convert to HSV, equalize only the V channel, and convert back. Contrast improves and the colors stay as they were.

Simplified

Use HSV to separate color from brightness, for example to find every purple-stained region whatever its strength. Use Lab to compare colors by number. Use Grayscale when an operation needs one intensity channel. For quantitative IHC, prefer Color Separation or OD conversion over grayscale.

Connected Terms

Share This Term
Term Connections