StrataQuest Home › StrataQuest Glossary › Optical Density Conversion
BOM Operation

Optical Density Conversion

RGB↔absorbance transform for brightfield quantification

View
Definition
Optical density (OD) measures how much light a sample absorbs. In general OD = −log₁₀(I/I₀), so each step of 1 means ten times less light gets through. StrataQuest has two operations under Color Conversions, Convert RGB to Optical Density (OD) and Convert Optical Density (OD) to RGB. Both rest on the Beer-Lambert lawLoading..., which relates the attenuation of light to the material it travels through.
Beer-Lambert Law
In general, OD is proportional to stain amount
Linearizes Staining
A logarithm turns exponential falloff into a line
Color Separation takes color
Its default input is the Original Image
Bidirectional Conversion
Two operations; the reference calls them lossless

How It Works

Hold a stained section up to a lamp. Where there is little stain, most of the light gets through; where there is a lot, little does. In general, each equal layer of stain passes the same fraction of the light reaching it, so transmitted light falls off exponentially with the amount of stain, and a camera records that falling transmission as pixel values.

Optical density undoes the exponential with a logarithm. In general, OD = −log₁₀(I / I₀), where I is the transmitted intensity and I₀ the intensity with no sample in the way. An OD of 1 means 10% of the light gets through, and an OD of 2 means 1%.

StrataQuest's two operations sit in the Basic Operations Module under Color ConversionsLoading.... The Engines Reference says Convert RGB to Optical Density (OD) is based on the Beer-Lambert law and gives a representation of the tissue thickness based on the observed light; Convert Optical Density (OD) to RGB applies the inverse law. It calls both conversions lossless, so the inverse can be applied. In the reference examples an 8-bit, 3-channel brightfield image of colon goes in and an 8-bit, 3-channel image comes out.

One detail is easy to miss. The reference notes that the OD formula, in theory, belongs to a grayscale image, but the engine applies it to each of R, G and B independently. So an RGB image becomes three OD channels, one per color, and in general that per-color view is what lets different stains be told apart, since each absorbs different colors.

The reference doesn't print the formula StrataQuest uses, say what intensity it takes as I₀, or say how OD values, which are not whole numbers, are scaled into an 8-bit output.

Simplified

Stain absorbs light. A camera records how much light got through, and that drops off steeply as stain builds up. Optical density takes a logarithm to turn this around, so twice the stain gives twice the OD. StrataQuest converts each color channel this way, and can convert back.

Image Processing Foundation

In general, the Beer-Lambert law was written for dyes in solution: absorbance equals ε·c·l, the stain's extinction coefficient times its concentration times the path length. It carries over to thin stained sections when absorption dominates, which is why OD is the usual scale for stain quantification in brightfieldLoading.... It fits less well for stains that scatter light as well as absorb it, and DABLoading... is generally regarded as one of those, so its OD tracks the amount of stain only roughly.

In pixel values, equal amounts of added stain make unequal steps. With I₀ = 255, an OD of 0.5 gives a pixel near 81 and an OD of 1.0 gives about 25, so the added stain moves the pixel 56 levels. From OD 1.5 to 2.0, the pixel goes from about 8 to about 3, only 5 levels. In OD, both steps are 0.5, the same amount of added stain.

In general, stain contributions add in OD and multiply in transmission, which is why color deconvolution methods, such as Ruifrok and Johnston's for hematoxylinLoading... and DAB, work in OD space. StrataQuest's Color SeparationLoading... engine describes its own methods instead: Single Reference Shades, an unmixing against reference shades you pick, and Multiple Reference Shades, a classification of pixels by color. Its reference doesn't mention OD, and its default input is the Original Image.

The term turns up elsewhere too. Filter specifications quote blocking as optical density: the TissueFAXS manual describes out-of-band blocking for a liquid crystal tunable filter as OD above 2, which corresponds to transmittance below 1%. The logarithm is the same; the object is different.

Simplified

Where several stains overlap, their effects multiply in raw pixel values but add in OD. That's why stain-separation math usually works in OD. StrataQuest's Color Separation engine uses its own methods and takes the color image directly.

Parameters & Settings

Convert RGB to Optical Density (OD)

ParameterDefaultDescription
ImageThe input image. Each channel of a 3-channel image is transformed independently.
Round modeRoundZeroThe rounding method used in the conversion. Deprecated, and due to be removed in a future version.

Convert Optical Density (OD) to RGB

ParameterDefaultDescription
ImageThe input image, in the Optical Density representation.
Round modeRoundZeroThe rounding method used in the conversion.

There is no direction setting: you choose the operation. There is no reference-white (I₀) setting either. The deprecated OD to absorbance operation under Legacy took Value – Red, Value – Green and Value – Blue, and the reference points to Convert Optical Density (OD) to RGB as its replacement. Because each module operation can use the outputs of earlier ones, an OD image can feed a thresholdLoading... or other later step in the same module.

Source: StrataQuest 8.1 Engines Reference, ch. 6.2 (pp. 92–100), ch. 6.12 (p. 355), ch. 6 (p. 19) and ch. 10 (pp. 382–383); TissueFAXS User Manual (p. 274).

Simplified

Pick the operation for the direction you want: RGB to OD, or OD back to RGB. The only other setting is a rounding mode, which you can leave at its default.

Connected Terms

Share This Term
Term Connections