ScientiaLux
strataquest Glossary Color Space Conversions
BOM Group

Color Space Conversions

Transforming between color representations

View
Definition
Operations for converting images between color representations — BGR↔HLS, BGR↔HSV, BGR↔Lab, and RGB to Grayscale — separating chromatic information from intensity for analysis tasks where hue and brightness need independent processing.
Four Color Spaces
HLS, HSV, Lab, and Grayscale
Separate Color from Brightness
Hue identifies stain type regardless of staining strength
Perceptual Uniformity (Lab)
Equal numerical distance = equal perceived difference
Non-Invertible Grayscale
RGB → Gray loses color information permanently

Operations Reference

ConversionOutput ChannelsKey Properties
BGR ↔ HLSHue (0–360°), Lightness (0–1), Saturation (0–1)Lightness = average of max and min RGB channels. Saturation varies with lightness.
BGR ↔ HSVHue (0–360°), Saturation (0–1), Value (0–1)Value = max RGB channel. More intuitive than HLS for image processing. Hue undefined when S=0 (grayscale).
BGR ↔ LabL* (0–100), a* (green↔red), b* (blue↔yellow)Perceptually uniform. L* channel is close to perceived lightness. a* and b* encode color information orthogonally.
RGB → GrayscaleSingle intensity channelWeighted average: I = 0.299R + 0.587G + 0.114B (NTSC weights). Non-invertible. Green-channel weighted because human vision is most sensitive to green.
Convert BGR ↔ HLSBidirectionalConvert to HLS for analysis, back to BGR for visualization.
Convert BGR ↔ HSVBidirectionalMost common color space conversion for image processing tasks.
Convert BGR ↔ LabBidirectionalBest for color comparison and perceptual analysis.
Simplified

These conversions transform images from raw camera RGB into color spaces that separate color from brightness. HSV is most commonly used — Hue tells you the color, Saturation tells you how vivid it is, Value tells you how bright. Lab is best for comparing colors because equal distances mean equal visual differences. Grayscale reduces to a single brightness channel.

When to Use Which

HSV for Stain Type Identification

In brightfield imaging, different chromogens (DAB brown, hematoxylin blue, Fast Red) have distinct hues. Converting to HSV and thresholding on the hue channel can separate stain types by color alone, regardless of staining intensity. This is a simpler alternative to full color deconvolution for some applications.

Lab for Color Distance

When comparing stain colors — e.g., determining whether two reference shades represent the same chromogen — Lab provides the most meaningful distance metric. Two colors with ΔE (Euclidean distance in Lab) < 2 are visually indistinguishable.

Grayscale for Single-Channel Processing

Many BOM operations (filtering, thresholding, morphology) require grayscale input. RGB to Grayscale converts color images to a single intensity channel using perceptually weighted averaging. Note: for quantitative IHC analysis, use Color Separation or OD conversion instead — they provide stain-specific channels rather than a generic intensity average.

Histogram Equalization in HSV

Solomon & Breckon warn that equalizing R, G, B channels independently "will alter the chromatic (colour hue) content." The correct approach: convert to HSV, equalize only the V channel, then convert back — this enhances contrast without distorting colors.

Simplified

Use HSV when you need to separate color from brightness — e.g., finding all purple-stained regions regardless of staining strength. Use Lab when comparing colors quantitatively. Use Grayscale when you need a single intensity channel for operations that don't understand color. For quantitative IHC analysis, prefer Color Separation or OD conversion over simple grayscale.

Connected Terms

Share This Term
Term Connections