![Page 1: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/1.jpg)
9A-L1 Color spaces
CS4495/6495 Introduction to Computer Vision
![Page 2: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/2.jpg)
Light Detection: Rods and Cones
Cones: • 6-7 million cones in the retina
• Responsible for high-resolution vision
• Discriminate colors
• Three types of color sensors (64% red, 32% green, 2% blue)
Rods
Cones
Image: anatomybox.com/retina-sem
![Page 3: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/3.jpg)
![Page 4: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/4.jpg)
Retina Mosaic
![Page 5: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/5.jpg)
Tristimulus Color Theory
Spectral-response functions of each of the three types of cones
• Can we use them to match any spectral color?
Percentage of light absorbed by each cone
![Page 6: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/6.jpg)
Color matching function based on RGB
Most spectral color can be represented as a positive linear combination of these primary colors (but…)
![Page 7: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/7.jpg)
Color matching function based on RGB
But some spectral cannot – need to add some red
R
![Page 8: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/8.jpg)
Color matching function based on RGB
![Page 9: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/9.jpg)
Luminance vs color
![Page 10: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/10.jpg)
CIE RGB color space
Color matching experiments [Wright & Guild 1920s]
• Mapped physical wavelengths to perceived colors
• Identified relative similarity and difference between colors
• Result: CIE RGB space defined
![Page 11: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/11.jpg)
Colors perceivable by the human eye
CIE xy chromaticity diagram, 1931
![Page 12: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/12.jpg)
CIE XYZ color space
A new space with desired properties
• Easy to compute – linear transform of CIE RGB
• Y: Perceived luminance
•X, Z: Perceived color
•Represents a wide range of colors
![Page 13: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/13.jpg)
Colors perceivable by the human eye
CIE xy chromaticity diagram, 1931
y =X
X + Y + Z
y =Y
X + Y + Z
![Page 14: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/14.jpg)
CIE L*a*b* color space
L = 25% L = 50% L = 75%
![Page 15: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/15.jpg)
Cylindrical view
Think of chroma (here a*, b*) defining a planar disc at each luminance level (L)
![Page 16: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/16.jpg)
HSL and HSV color spaces
![Page 17: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/17.jpg)
Quiz: Hue difference
If hue values range in [0, 360], what is the absolute difference between the following pairs of hues?
• 225 and 75
• 45 and 315
![Page 18: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/18.jpg)
Quiz: Hue difference
If hue values range in [0, 360], what is the absolute difference between the following pairs of hues?
• 225 and 75
• 45 and 315
150
90 Hue is an angular measure, it “wraps around” at 0/360
![Page 19: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/19.jpg)
But there are lots of color spaces
![Page 20: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/20.jpg)
My favorite
![Page 21: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/21.jpg)
The one we know best…
•RGB color space
![Page 22: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/22.jpg)
Like a squared double cone?
![Page 23: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/23.jpg)
Color gamuts
![Page 24: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/24.jpg)
![Page 25: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/25.jpg)
![Page 26: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/26.jpg)
![Page 27: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/27.jpg)
Revisiting pixels
“Picture element” at location (𝑥, 𝑦), value or color 𝑐
𝑋
𝑌
𝑐 = (150, 173, 81) 𝑥 = 243
𝑦 = 84
![Page 28: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/28.jpg)
Color values are vectors, here (R, G, B)
(150, 173, 81)
(254, 255, 251)
(152, 52, 50)
![Page 29: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/29.jpg)
𝑅
𝐺 𝐵
RGB Color Space
(150, 173, 81) (254, 255, 251)
(152, 52, 50)
Image Space
![Page 30: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/30.jpg)
![Page 31: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/31.jpg)
Quiz: Plotting pixels in a color space
What does this view enable us to do?
Think about clusters of pixels that are similar in color
Understand the shape and size of objects present
Identify pixels that are different, and separate them
Count how many pixels of each color there are
![Page 32: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/32.jpg)
Quiz: Plotting pixels in a color space
What does this view enable us to do?
Think about clusters of pixels that are similar in color
Understand the shape and size of objects present
Identify pixels that are different, and separate them
Count how many pixels of each color there are
![Page 33: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/33.jpg)
Example: Red filter
Filter: 𝑅 ∈ 0,255 ,
𝐺 ∈ 0,100 , 𝐵 ∈ 0,100
![Page 34: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/34.jpg)
Example: Red filter – more red!
Filter: 𝑅 ∈ 0,255 ,
𝐺 ∈ 0,50 , 𝐵 ∈ 0,50
![Page 35: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/35.jpg)
How intensity affects color values
Just different shades of green, but all 3 values change!
(150, 173, 81) (75, 87, 41) (210, 220, 180)
Darker Lighter
![Page 36: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/36.jpg)
Solution: Separate intensity and color
Define intensity (𝑌) as some combination of 𝑅, 𝐺, 𝐵
𝑌 = 𝑊𝑅 × 𝑅 + 𝑊𝐺 × 𝐺 + 𝑊𝐵 × 𝐵 = 0.299 × 𝑅 + 0.587 × 𝐺 + 0.114 × 𝐵
![Page 37: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/37.jpg)
Solution: Separate intensity and color
Then compute new color values, taking out intensity
𝑈 = 𝑈𝑚𝑎𝑥
𝐵 − 𝑌
1 − 𝑊𝐵≈ 0.492 × 𝐵 − 𝑌
𝑉 = 𝑉𝑚𝑎𝑥
𝑅 − 𝑌
1 − 𝑊𝑅≈ 0.877 × 𝑅 − 𝑌
Assuming 𝑅, 𝐺, 𝐵 and 𝑌 are in the range 0,1
𝑈 ∈ −𝑈𝑚𝑎𝑥 , 𝑈𝑚𝑎𝑥 and 𝑉 ∈ −𝑉𝑚𝑎𝑥 , 𝑉𝑚𝑎𝑥
![Page 38: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/38.jpg)
Together: 𝑌𝑈𝑉
𝑌
𝑈 𝑉
![Page 39: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/39.jpg)
![Page 40: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/40.jpg)
![Page 41: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/41.jpg)
Quiz: UV filter
What UV limits should we use to extract red regions?
Filter: 𝑌 ∈ 0,255 , 𝑈 ∈ , , 𝑉 ∈ ,
![Page 42: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/42.jpg)
Quiz: UV filter
What UV limits should we use to extract red regions?
Filter: 𝑌 ∈ 0,255 , 𝑈 ∈ 130,200 , 𝑉 ∈ 100, 130
![Page 43: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/43.jpg)
UV filter
Filter: 𝑌 ∈ 0,255 ,
𝑈 ∈ 130,200 , 𝑉 ∈ 100,130
![Page 44: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/44.jpg)
![Page 45: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/45.jpg)
YUV filter
Filter: 𝑌 ∈ 0,150 ,
𝑈 ∈ 130,200 , 𝑉 ∈ 100,130
![Page 46: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/46.jpg)
Comparing RGB and YUV filters
Filter: 𝑌 ∈ 0,150 ,
𝑈 ∈ 130,200 , 𝑉 ∈ 100,130
Filter: 𝑅 ∈ 0,255 ,
𝐺 ∈ 0,50 , 𝐵 ∈ 0,50
![Page 47: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/47.jpg)
Intuition: Why YUV?
• Easier clustering of pixels
• Efficient encoding by chroma subsampling
• Recall, human vision is more sensitive to intensity changes
• Y channel can now use more bits
• E.g., YUV422 – to represent 2 image pixels, it uses 2 bytes for Y, and 1 byte each for U and V
![Page 48: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/48.jpg)
Other luma-chroma color spaces
• YCbCr/YPbPr – video transmission, compression
•CIE L*a*b*
• Based on human perception
• Intensity channel: L* = lightness
• Color-opponent: a* = red-green, b* = blue-yellow
•CIE L*u*v* – like L*a*b* but easier to compute
![Page 49: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/49.jpg)
Back to plotting image pixels
![Page 50: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/50.jpg)
Plotting in HSV
Focus on HS projection – what do you see?
Colors spread along a single dimension!
Hue
![Page 51: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/51.jpg)
A better HS plot
Treat hue as an angle
• Reds from both ends of the spectrum now in proximity
• Better reflects the role of saturation (radius or distance from center)
![Page 52: CS4495/6495 Introduction to Computer Vision...Intuition: Why YUV? •Easier clustering of pixels •Efficient encoding by chroma subsampling •Recall, human vision is more sensitive](https://reader030.vdocument.in/reader030/viewer/2022040406/5ea2bc13986afb2d6a0eaabb/html5/thumbnails/52.jpg)
Exercise: HSV filter
• Filter this image in HSV to select red apples
•Compare best results from RGB, YUV, L*a*b*