Alternative University

Computer Science

Raster Image Storage

Higher Precision Extended Range

XRH File Format 3.0

Color Transformations

If a pictorial color image is stored as red, green and blue (RGB) channels, it must use lossless compression to avoid smearing of primary colors.

If the three color channels of a pictorial color image use lossy compression, storage as RGB channels is not suitable, because lossy compression spatially affects different channels differently, causing primary colors to smear relative to each other.

To use lossy compression, the three color channels must be decorrelated. For effective high definition color decorrelation, the XRH file format uses ITU-R BT.709, which converts RGB channels to decorrelated YCbCr channels (one intensity channel denoted Y, and two chroma difference channels denoted Cb and Cr). It is the YCbCr channels that are compressed and stored, instead of the RGB channels.

The following formulas (Figure 1) convert RGB colors to YCbCr:

αr = 0.2126   αg = 0.7152   αb = 0.0722

Y = αr · R + αg · G + αb · B

Cb = 0.5 (B − Y) ⁄ (1 − αb)

Cr = 0.5 (R − Y) ⁄ (1 − αr)

Figure 1.

Y is the image intensity (luminance). It is the weighted average of the RGB channels. The weights (αr αg and αb) are derived from the following chromaticities (Figure 2):

xr = 0.6400   yr = 0.3300
xg = 0.3000   yg = 0.6000
xb = 0.1500   yb = 0.0600
xw = 0.3127   yw = 0.3290

Figure 2.

Those are the default chromaticities that are automatically used if zero is specified for the chromaciticities in the XRH file header.

To use weights other than the weights shown in Figure 1, specify other chromaticities in the XRH file header.

Color transformation using ITU-R BT.709 is performed if 1 is stored in Color Transformation Type integer of the XRH file header. In that case, the first channel of the file is a Y channel of Cb and Cr channels that follow in that order, with the ITU-R BT.709 transformation performed on those three channels.

To use a color transformation other than ITU-R BT.709 as described in this page, store zero in the channel Color Transformation Type integer of the XRH file header.

New Version Available

Newer XRH version recommended for new applications:

XRH version 4.0

< Prev: SZMOD Compression    
    Next: Sample Files >
XRH 3.0 File Format
Page 1 : 
Page 2 : 
Page 3 : 
Page 4 : 
Page 5 : 
Page 6 : 
Page 7 : 
Page 8 : 
Page 9 : 
Page 10 : 
File Layout & Header
Custom Properties
Channel Names
Zebra Compression
SZMOD Compression
Color Transformations (this page)
Sample Files