**Algorithms and reference formulas**

This page contains algorithms and reference formulas for Colorcheck, Multitest, and Multicharts. It’s all in ** green text ** because it’s all math.

*Color difference (error) formulas *

*Color difference (error) formulas*

**You have two rectangular patches with different colors. How different are they? **

The Wikipedia Color Difference page has a concise introduction to color difference concepts and equations. This page (written before the Wikipedia page was available) covers similar material.

The notation on this page is adapted from the Digital Color Imaging Handbook, edited by Gaurav Sharma, published by the CRC Press, referred to below as DCIH. The DCIH online Errata was consulted.

In measuring color error, keep it in mind that * accurate* color is not necessarily the same as

*color. Many manufacturers deliberately alter colors to make them more pleasing, typically by increasing saturation. (That is why Fujichrome Velvia was so successful when it was introduced in 1990.) In calculating color error, you may choose not to use the exact Colorchecker (or other chart) L*a*b* reference values; you may want to substitute your own enhanced values. Imatest Master allows you to enter reference values from a file written in CSV format (you can save the values from a measured chart using Multicharts).*

**pleasing**Imatest users frequently ask about the meaning of “corr” and “uncorr” in the Colorcheck a*b* error plot. Corr means that the mean saturation (mean chroma = mean(sqrt(a*^{2}+b*^{2})) of the camera is adjusted to be the same as that of the reference before making the comparison. This is a very easy correction to make; it tells how accurate the color hue would be if the mean chroma were were the same as the reference. See below for more detail.

*Absolute differences (including luminance)*

*Absolute differences (including luminance)*

**CIE 1976 **

**CIE 1976**

The L*a*b* color space was designed to be * relatively* perceptually uniform. That means that perceptible color difference is approximately equal to the Euclidean distance between L*a*b* values. For colors {

*L**,

_{1}*a**,

_{1}*b**} and {

_{1}*L**,

_{2}*a**,

_{2}*b**}, where Δ

_{2}*L** =

*L** –

_{2}*L**, Δ

_{1}*a** =

*a** –

_{2}*a**, and Δ

_{1}*b** =

*b** –

_{2}*b**,

_{1}**Δ E*_{ab} = ( ( ΔL*)^{2} + (Δa*)^{2} + (Δb*)^{2} )**

^{1/2}(DCIH (1.42, 5.35); (…)

^{1/2}denotes square root of (…) ).

Although Δ*E* _{ab}* is relatively simple to calculate and understand, it’s not very accurate especially for strongly saturated colors. L*a*b* is not as perceptually uniform as its designers intended. For example, for saturated colors, which have large chroma values (

*C** = (

*a**

^{2}+

*b**

^{2})

^{1/2}), the eye is less sensitive to changes in chroma than to corresponding changes for Hue (Δ

*H**= ( (Δ

*E**)

_{ab}^{2}– (Δ

*L**)

^{2}– (Δ

*C**)

^{2})

^{1/2}) or Luminance (Δ

*L**). To address this issue, several additional color difference formulas have been established. In these formulas, just-noticeable differences (JNDs) are represented by

*ellipsoids*rather than circles.

**CIE 1994 **

**CIE 1994**

The CIE-94 color difference formula, Δ*E**_{94}, provides a better measure of perceived color difference than **Δ E*_{ab} **.

Δ*E**_{94} = ( (Δ*L**)^{2} + (Δ*C** ⁄ *S _{C }*)

^{2}+ (ΔH* ⁄ S

_{H })

^{2})

^{1/2}(DCIH (5.37); omitting constants set to 1 ), where

*S _{C}* = 1 + 0.045

*C** ;

*S*= 1 + 0.015

_{H}*C** (DCIH (1.53, 1.54) )

[ *C** = ( ( *a _{1}**

^{2}+

*b**

_{1}^{2})

^{1/2}(

*a**

_{2}^{2}+

*b**

_{2}^{2})

^{1/2})

^{1/2}(the geometrical mean chroma) gives symmetrical results for colors 1 and 2. However, when one of the colors (denoted by subscript

*s*) is the standard, the chroma of the standard,

*C*

** = (*

_{s}*a**

_{s}^{2}+

*b**

_{s}^{2})

^{1/2}, is preferred for calculating

*S*and

_{C}*S*. The asymmetrical equation is used by Bruce Lindbloom.]

_{H}Δ*H** = ( (Δ*E* _{ab}*)

^{2}– (Δ

*L**)

^{2}– (Δ

*C**)

^{2})

^{1/2}(hue difference ; DCIH (5.36) )

Δ*C** = ( *a _{1}**

^{2}+

*b**

_{1}^{2})

^{1/2}– (

*a**

_{2}^{2}+

*b**

_{2}^{2})

^{1/2}(chroma difference)

CMC The CMC color difference formula is widely used by the textile industry to match bolts of cloth. It was one of the best measurement metrics prior to CIEDE2000, but it hasn’t gained traction in the photographic industry. It is slightly asymmetrical: subscript
⁄ cS)_{C }^{2} + (ΔH* ⁄ S)_{H }^{2} )^{1/2} (DCIH (5.37) ), where(That’s the lowercase letter ^{2}.) ΔE*_{CMC}(1,1) (l = c = 1) is used for graphic arts perceptibility mesurements. l = 2 is used in the textile industry for acceptibility of fabric matching. For now Imatest displays ΔE*_{CMC}(1,1).
L* ⁄ (1+0.01765 _{s}L*) ; _{s}L* ≥ 16 (DCIH (1.48) ) = 0.511 ; _{s}L* < 16_{s}
C* ⁄ (1+0.0131 ) + 0.638 ; _{s}S = _{H}S (_{C}T + 1 – _{CMC }F_{CMC}F) (DCIH (1.49, 1.50) )_{CMC }
C*)_{s}^{4} ⁄ ( ( C*)_{s}^{4} + 1900 ) ) (DCIH (1.51);^{1/2}
h* + 168°) | 164° ≤ _{s}h* ≤ 345° (DCIH (1.52) ) = 0.36 + | 0.4 cos(_{s}h* + 35 °) | otherwise _{s}Δ |

**CIEDE2000**

**CIEDE2000**

The CIEDE2000 formulas (Δ*E*_{oo} and Δ*C*_{oo} ) are the upcoming standard, and may be regarded as more accurate than the previous formulas. We omit the equations here because they are described very well on Gaurav Sharma’s CIEDE2000 Color-Difference Formula web page. Default values of 1 are used for parameters *k _{L}*,

*k*, and

_{C}*k*.

_{H}At the time of this writing (February 2008) the CIE 1976 color difference metrics (Δ*E* _{ab}*…) are still the most familiar. CIE 1994 is more accurate and robust, and retains a relatively simple equation. Δ

*E**

_{CMC}is more complex but widely used in the textile industry. The complexity of the CIEDE2000 equations (DCIH, section 1.7.4, pp. 34-40) has slowed their widespread adoption, but they are on their way to becoming the accepted standard.

**For the long run, CIEDE2000 color difference metrics are the best choice.**

*Chroma differences ΔC (color differences that omit luminance difference) *

*Chroma differences ΔC (color differences that omit luminance difference)*

Exposure errors strongly affect color differences Δ*E* _{ab}*, Δ

*E**

_{94}, and Δ

*E**

_{00}. Since it is useful to look at color errors independently of exposure error, we define color differences that omit Δ

*L**.

**Δ C_{ab} = ((Δa*)^{2} + (Δb*)^{2} )^{1/2}**

= **((Δ E*_{ab})^{2} – (ΔL*)^{2} )^{1/2}** (This is a more general form: Delta-E with Delta-L removed.)

**Δ C_{94} = ( (ΔC***

**⁄**

*S*)_{C }^{2}+ (Δ*H** ⁄*S*)_{H }^{2})^{1/2}**Δ C_{CMC} = ((ΔC***

**⁄**

*S*)_{C }^{2}+ (Δ*H** ⁄*S*)_{H }^{2})^{1/2}

**Δ C_{00} **omits the

**( Δ**term from the

*L’ ⁄ k*)_{L}S_{L}^{2}**Δ**(square root) equation (see Sharma).

*E*_{00 }These formulas don’t entirely remove the effects of exposure error since a* and b* are affected somewhat by exposure, but they reduce it to a manageable level. Note that the **Δ C** definition can cause some confusion because it is different from the pure chroma difference,

**Δ***, where chroma =

*C**** = sqrt(a***

*C*^{2}+ b*

^{2}).

**Δ*** is not suitable as a perceptual measurement because it does not include hue.

*C**Color differences corrected for chroma (saturation) boost/cut*

*Color differences corrected for chroma (saturation) boost/cut*

Many digital cameras deliberately boost chroma, i.e., saturation, to enhance image appearance in digital cameras. This boost increases color error in the Δ*E** and Δ*C* formulas, above.

The mean chroma percentage is

*Chrp* = 100% * (measured mean( (*a _{i}**

^{2}+

*b**

_{i}^{2})

**) ) ⁄ (Colorchecker mean( (**

^{1/2}*a**

_{i}^{2}+

*b**

_{i}^{2})

**) )**

^{1/2} = 100% * mean (*C*_{measured}) ⁄ mean (*C*_{ideal}) ; *C _{i }* = (

*a**

_{i}^{2}+

*b**

_{i}^{2 })

^{1/2} 1 ≤ *i* ≤ 18 (the first three rows of the Colorchecker)

Chroma, which is closely related to the perception of saturation, is boosted when *Chrp* > 100. Chroma boost increases color error measurements Δ*E* _{ab}*, Δ

*C**, Δ

_{ab}*E**, and Δ

_{94}*C**. Since it is easy to remove chroma boost in image editors (with saturation settings), it is useful to measure the color error after the mean chroma has been corrected (normalized) to 100%. To do so, normalized

_{94}*a*and

_{i_corr}*b*are substituted for measured (camera) values

_{i_corr}*a*and

_{i}*b*in the above equations.

_{i}*a _{i_corr}* = 100

*a*⁄

_{i}*Chrp*;

*b*= 100

_{i_corr}*b*⁄

_{i}*Chrp*

The reference values for the ColorChecker are unchanged. Color differences corrected for chroma are denoted Δ*C* _{ab}*(corr), Δ

*C**(corr), and Δ

_{94}*C**(corr).

_{CMC}*Mean and RMS values*

*Mean and RMS values*

Colorcheck Figure 3 reports the mean and RMS values of Δ*C*** _{ab}* corrected (for saturation) and uncorrected, where

mean(*x*) = Σ*x _{i}* ⁄

*n*for n values of x.

RMS(*x*) = σ(*x*) = (Σ*x _{i}^{2}* ⁄

*n*)

^{1/2}for n values of x.

The RMS value is of interest because it gives more weight to the larger errors.

*Colorcheck Algorithm*

*Colorcheck Algorithm*

- Locate the regions of interest (ROIs) for the 24 ColorChecker zones.

- Calculate statistics for the six grayscale patches in the bottom row, including the average pixel levels and a second order polynomial fit to the pixel levels in the ROIs— this fit is subtracted from the pixel levels for calculating noise. It removes the effects of nonuniform illumination. Calculate the noise for each patch.

- Using the average pixel values of grayscale zones 2-5 in the bottom (omitting the extremes: white and black), the average pixel response is fit to a mathematical function (actually, two functions). This requires some explanation.

A simplified equation for a capture device (camera or scanner) response is,

**normalized pixel level = (pixel level ⁄ 255) = k _{1 }exposure^{gamc}**

Gamc is the ** gamma** of the capture device. Monitors also have gamma = gamm defined by

**monitor luminance = (pixel level ⁄ 255) ^{gamm}**

Both gammas affect the final image contrast,

**System gamma = gamc * gamm**

Gamc is typically around 0.5 = 1/2 for digital cameras. Gamm is 1.8 for Macintosh systems; gamm is 2.2 for Windows systems and several well known color spaces (sRGB, Adobe RGB 1998, etc.). Images tend to look best when system gamma is somewhat larger than 1.0, though this doesn’t always hold— certainly not for contrasty scenes. For more on gamma, see Glossary, Using Imatest SFR, and Monitor calibration.

Using the equation, **density = – log _{10}(exposure) + k**,

**log _{10}(normalized pixel level) = log_{10}( k_{1 }exposure^{gamc} ) = k_{2} – gamc * density**

This is a nice first order equation with slope gamc, represented by the **blue** dashed curves in the figure. But it’s not very accurate. A second order equation works much better:

**log _{10}(normalized pixel level) = k_{3} + k_{4} * density + k_{5} * density^{2}**

k_{3}, k_{4}, and k_{5} are found using second order regression and plotted in the **green** dashed curves. The second order fit works extremely well.

- Saturation S in HSV color representation is defined as S(HSV) = (max(R,G,B)-min(R,G,B)) ⁄ max(R,G,B). S correlates more closely with perceptual White Balance error in HSV representation than it does in HSL.

The the equation for saturation boost in the lower image of the third figure is S’ = (1-e^{-4S }) ⁄ (1-e^{-4}), where e = 2.71828…

*Grayscale levels and exposure error *

*Grayscale levels and exposure error*

Colorchecker grayscale patch densities (in the bottom row) are specified as 0.05, 0.23, 0.44, 0.70, 1.05, and 1.50. Using the equation, pixel level = 255 * (10^{–density} ⁄ 1.06)^{(1/2.2)} (see ISO speed, below), the ideal pixel levels would be 236, 195, 157, 119, 83, and 52, about 3% lower than the values measured by Bruce Lindbloom (242, 201, 161, 122, 83, and 49 for the Green channel) and provided with a Colorchecker purchased in October 2005 (243, 200, 160, 122, 85, 52). On the average, these measured values fit the equation,

pixel level = 255 * (10^{–density} ⁄ 1.01)^{(1/2.2)}

Colorchecker Exposure error is measured by comparing the measured pixel levels of patches 2-5 in the bottom row (20-23 in the chart as a whole) with the selected reference levels. White and black patches 1 and 6 of the bottom row (19 and 24) are omitted because they frequently clip.

Gamma is the average slope of log pixel level vs. Log exposure, measured from patches 2-5 in the bottom row, shown on the right as a diagonal dotted blue line (**·········**). Pixel level is approximately proportional to exposure^{gamma}, hence log_{10}(exposure) is proportional to log_{10}(pixel level) ⁄ gamma, the log exposure error for an individual patch is

Δ(log exposure) = (log_{10}(measured pixel level) – log_{10}(reference level)) ⁄ gamma

Using the mean value of Δ(log exposure) for patches 2-5 and the equation, f-stops = 3.32 * log exposure,

Exposure error in f-stops = 3 32 * (mean(log_{10}(measured pixel level) – log_{10}(reference level))) ⁄ gamma

For Stepchart linear grayscale charts, patches 4 & larger are used for calculating Exposure error.

**ISO sensitivity**

**ISO sensitivity**

Two types of ISO sensitivity are calculated: Saturation-based Sensitivity and Standard Output Sensitivity. These measurements are described on the ISO Sensitivity page.