This document provides an overview of color theory and color models used in digital images and video. It discusses how the human visual system perceives color and light, and various color spaces such as RGB, YUV, YCbCr. The document also covers color decimation, packing, and conversions between different color formats like 4:4:4, 4:2:2, 4:2:0. Hands-on exercises demonstrate repacking video files between different color models and formats using FFmpeg.
3. 3
Hands-on Video Course
Losless Compression
Model Based Compression
Model
Based
Transform/s
Quantize /
Prioritize Reorder
Entropy
Coding
Sample +Pre
Processing
Bit rate control
5. 5
Hands-on Video Course
Human Visual System
The human eye has two basic light receptors:
Rods – Light Intensity receptors
Cons – Colored light receptors
7. 7
Hands-on Video Course
4.2 Color Models in Images
Colors spaces are used to store, display, print
images.
Images are represented using different:
Color spaces
Color Depth
Color Decimation Methods
Pixel/Plane Interleaving methods
8. 8
Hands-on Video Course
Color Spaces
Color Spaces
RGB – Each pixel is provided coordinates in 3D space.
Coordinates are in Red, Blue and Green. This is how we
perceive color
YUV – Conversion of the color to a Light (Y) based system.
Y and V are Color Complements
HSV – Hue, Saturation, Value
YCbCr and more
10. 10
Hands-on Video Course
Color matching
How can we compare colors
so that the content creators
and consumers know what
they are seeing?
Many different ways
including CIE chromacity
diagram
11. 11
Hands-on Video Course
Video Color Transforms
Largely derived from older analog methods of coding
color for TV. Luminance is separated from color
information.
YIQ is used to transmit TV signals in North America and
Japan.This coding also makes its way into VHS video
tape coding in these countries since video tape
technologies also use YIQ.
In Europe, video tape uses the PAL or SECAM codings,
which are based on TV that uses a matrix transform
called YUV.
Finally, digital video mostly uses a matrix transform called
YCbCr that is closely related to YUV
13. 13
Hands-on Video Course
YUV Color Model
•YUV codes a luminance signal (for gamma-corrected
signals) equal to Y , the “luma".
•Chrominance refers to the difference between a color
and a reference white at the same luminance. (U and V)
The transform is:
14. 14
Hands-on Video Course
YIQ Color Model
YIQ is used in NTSC color TV broadcasting.
Again, gray pixels generate zero (I;Q)
chrominance signal.
I and Q are a rotated version of U and V .
The transform is:
15. 15
Hands-on Video Course
YCbCr Color Model
1. The Rec. 601 standard for digital video uses
another color space YCbCr which closely
related to the YUV transform.
2. The YCbCr transform is used in JPEG image
compression and MPEG video compression.
For 8-bit coding:
16. 16
Hands-on Video Course
Color Decimation
Rods>>Cons
Spatial Representation(Light) >> SR(Color)
Current Representation of light by 3 coordinates
per pixel waste space.
Color Decimation is done only in Light based color
representation (not in RGB)
17. 17
Hands-on Video Course
Color Decimation
YUV 4:4:4 – No Color decimation
Used in studio editing
WiFi Display
YUV 4:2:2 – UV are decimated by two
High end video coding
YUV 4:2:0 – UV pixels are decimated by 4
Standard video coding
UY V
UY V
U
Y
V
18. 18
Hands-on Video Course
Color Packing
We could arrange the “Color” pixels in several
ways:
Packed:
YUV|YUV|YUV
Planer:
YYYYYY….UUUUU…..VVVVV
Semi Planer:
YYYYYYY UVUVUV
19. 19
Hands-on Video Course
Common Color Packing formats
For video coding well use
Progressive input (and not interleaved)
YUV 4:2:0 Decimation
Planer Color Packing (yuv420p / I420)
22. 22
Hands-on Video Course
YUV Player
Did you got this? Why?
1. It seems that YUV file-format does not hold
format information
2. There are many YUV formats
What to do?
24. 24Hands-on Video Course
Play & Probe file
FFPLAY akiyo_cif.y4m
FFProbe akiyo_cif.y4m
Input #0, yuv4mpegpipe, from 'akiyo_cif.y4m':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p,
352x288, SAR 128:117 DAR 1408:1053, 29.97 fps, 29.97
tbr, 29.97 tbn, 29.97 tbc
25. 25Hands-on Video Course
Back to YUV Player
Select YUV420
And if we need it in UYVY (YUV422 Packed)
ffmpeg -s 352x288 -i akiyo_cif.yuv -pix_fmt
uyvy422 akiyo_cif_uyvy.yuv
26. 26Hands-on Video Course
Ex 1
Create Akiyo YUV file which is opened using
YUV422 option of YUVPlayer
What is the difference between this 4:2:2 format
and the previous one?
Can we open this format using Y only setting?
If not create a Y only file
Is there an option for a YUV file with headers?
Save akiyo in raw YUV with headers