Colour. Leow Wee Kheng. CS4243 Computer Vision and Pattern Recognition.
CS4243. Colour. 1 ..... Billmeyer and Saltzman's Principles of Color. Technology.
Leow Wee Kheng CS4243 Computer Vision and Pattern Recognition
Colour
CS4243
Colour
1
Colour is everywhere!
CS4243
Colour
2
CS4243
Colour
3
You already know enough about colour? Let’s do a test…
CS4243
Colour
4
+ CS4243
=? Colour
5
+ CS4243
=? Colour
6
+ CS4243
=? Colour
7
So, there’s a lot more to colour!
CS4243
Colour
8
Human Colour Perception
Human’s eye has retina that senses light.
retina
CS4243
Colour
9
Human’s retina has 2 kinds of light receptors: Rods:
sensitive to amount of light Cones:
sensitive to lights of different wavelengths
CS4243
Colour
10
Cones are sensitive to various colours Wavelengths
CS4243
from 400nm (violet) to 700nm (red)
Colour
11
3 kinds of cones: Short
(S): most sensitive to blue Medium (M): most sensitive to green Long (L): most sensitive to red
CS4243
Colour
12
Cones send signals to brain.
Brain interprets mixture of signals as colours.
That’s why colours are coded with 3 values.
Different coding schemes give different colour spaces.
CS4243
Colour
13
RGB Colour Space
Colour is coded with 3 values (red, green, blue)
CS4243
Colour
14
Each value is an unsigned 8-bit value: (0,
0, 0) is black (255, 0, 0) is red (0, 255, 0) is green (0, 0, 255) is blue (128, 128, 128) is gray (255, 255, 255) is white
CS4243
Colour
15
HSV Colour Space
Code colour as hue, saturation, value. Also
CS4243
called HSB (B for brightness).
Colour
16
Hue colour
type 0° (red) to 360°
Saturation Colourfulness 0
to 1 (full colour)
Value Brightness 0
CS4243
(black) to 1 (white)
More intuitive than RGB. Colour
17
HSL Colour Space
Code colour as hue, saturation, lightness. Similar
CS4243
to HSV, also called HLS.
Colour
18
Hue colour
type 0° (red) to 360°
Saturation Colourfulness 0
to 1 (full colour) Full saturation defined at L = 0.5
Lightness 0
CS4243
(black) to 1 (white)
Colour
19
YCbCr Colour Space
Code colour as Y, Cb, Cr. Used
CS4243
for TV, video.
Colour
20
Y: luminance
Cb: blue difference
Cr: red difference
For unsigned 8-bit encoding, these values range from 0 to 255.
Often confused with YUV.
CS4243
Colour
21
Colour Difference
Consider two colours C1 and C2.
How to measure difference between C1 and C2?
Simplest difference measure: Euclidean distance
d (C1 , C2 ) = Straight
CS4243
(R1 − R2 ) + (G1 − G2 ) + (B1 − B2 ) 2
2
2
line distance in RGB space.
Colour
22
Let’s do a test… Which colour looks more similar to the middle colour, left or right?
CS4243
Colour
23
Perceptually Uniform Colour Spaces
RGB space is not perceptually uniform colour distance ⇒ equal perceptual difference Inappropriate if need to match human perception. Equal
HSV, HSL, YCbCr also not perceptually uniform.
Perceptually (more) uniform colour spaces: Munsell
colour space
CIELAB CIELUB
CS4243
Colour
24
Munsell Colour Space
Code colour as hue, value, chroma. chroma:
colourfulness Difficult to use.
CS4243
Colour
25
CIELAB
CS4243
CIE 1976 L*a*b* colour space
Colour
26
L* : matches human perception of lightness From
0 (black) to 100 (white).
a*, b*: hue
+b
yellow
green
red
−a
+a
−b CS4243
Colour
blue 27
CIELUV
CIE 1976 L*u*v* Similar
to CIELAB colour space. L* : range from 0 to 100. u*, v*: typically range from –100 to +100.
CS4243
Colour
28
Colour Arithmetic
How to add, subtract, average colours correctly?
If not careful, can produce invalid colours.
CS4243
Colour
29
Addition
With unsigned 8-bit, cannot have value > 255.
Usually clip to maximum value.
For example,
R1 + R2 R= 255
CS4243
if R1 + R2 < 255 otherwise
Similarly for G, B.
Colour
30
image sum 2 1
CS4243
Colour
31
image sum 2 1
CS4243
Colour
32
Subtraction
With unsigned 8-bit, cannot have value < 0.
Usually clip to minimum value.
For example,
R1 − R2 R= 0
CS4243
if R1 − R2 > 0 otherwise
Similarly for G, B.
Colour
33
difference image 2 1
CS4243
Colour
34
difference image 2 1
CS4243
Colour
35
Average
Usual way of computing mean: n
sum
S = ∑ Ri i =1
divide With
unsigned 8-bit value, S can overflow for small n.
Clipping Need
CS4243
1 M= S n
S produces inaccurate average.
better methods.
Colour
36
Average
Method 1: Floating point representation. Then, S doesn’t overflow unless n is very large. S is not a valid colour value. 1 S truncated to unsigned 8-bit is valid. Mean M = n
CS4243
Colour
37
Average
Method 2: Incremental average With only 1 colour R1, mean = R1 M 1 = R1
With
two colours R1, R2,
1 1 1 M 2 = (R1 + R2 ) = M 1 + R2 2 2 2 With k colours R1, R2,…, Rk, 1 k −1 1 M k = (R1 + + Rk ) = M k −1 + Rk k k k k −1 1 M k −1 , Rk are all valid colours. Mk, k k CS4243
Colour
38
image mean 2 1
CS4243
Colour
39
image mean 2 1
CS4243
Colour
40
mean over 8-sec video
CS4243
Colour
41
Colour-Difference Equations
Consider a reference colour C0.
Euclidean distance of C1 from C0 in CIELAB / CIELUV space:
More
CS4243
perceptually uniform than in RGB space. Colour
42
CS4243
Can also define as:
Colour
43
Further improvements: CIE94, CMC, BFD.
More perceptually uniform than Euclidean distance in CIELAB / CIELUV colour space.
CIE94
CS4243
Colour
44
Summary
Colours have 3 components.
Most colour spaces are not perceptually uniform.
CIELAB/CIELUV are perceptually more uniform.
Be careful with colour arithmetic.
Use appropriate colour-difference equation.
CS4243
Colour
45
Further Reading
Conversion formulae for colour spaces OpenCV
user guide Wikipedia
Colour-difference equations: [Leow2002]
CIE94, CMC, BFD: [Berns2000, Leow2002]
CS4243
Colour
46
References
R. S. Berns. Billmeyer and Saltzman’s Principles of Color Technology. John Wiley & Sons, 3 edition, 2000.
W. K. Leow, Color Spaces and Color-Difference Equations. Tech Report, NUS, 2002.
CS4243
Colour
47