You are on page 1of 67

Image Processing

COMP4421
Dr. Hao CHEN
Dept. of CSE, HKUST
We have covered…

World is colorful!

2
Color Image Processing

Why Color?

• Powerful descriptor
for object detection and feature extraction

• Easy for humans to discern


thousands of color shades
vs.
two dozen shades of gray

3
Color Image Processing

Two major areas:

• Pseudo-color processing
• Full-color processing

4
Color Image Processing
We will cover:
• Color Fundamentals
• Color Models
• RGB, CMY and CMYK, HSI
• Color Image processing
• Pseudo color image processing
• Full color image processing
• Full Color Image Processing
• Color transformations
• Color image smoothing and sharpening
• Color image segmentation
• Noise in color models
5
Color Image Processing
We will cover:
• Color Fundamentals
• Color Models
• RGB, CMY and CMYK, HSI
• Color Image processing
• Pseudo color image processing
• Full color image processing
• Full Color Image Processing
• Color transformations
• Color image smoothing and sharpening
• Color image segmentation
• Noise in color models
6
Color Fundamentals

Color spectrum by passing white light through prism.


Discovered by Isaac Newton, 24-year-old in 1666.

7
Color Fundamentals
• Perceived color depends on spectral content (wavelength composition)
• e.g., 700nm ~ red.
• A light with equal energy in all visible bands appears white

8
Color Fundamentals
 The colors that humans perceive of an object are
determined by the nature of the light reflected from
the object.
 Incident light (electromagnetic wave) →human eye.
 The light is visible to human eyes if its
wavelength is between 380-780 (nm).
 Human eyes have the following sensitivity :
 Brightness: light intensity (energy)

 Color: different spectral composition

9
Human Perception of Color
Quantities describing a chromatic light source
 Radiance: total amount of energy from the light source (Watt, W)
 Luminance: a measure of the amount of energy by an observer
(Lumens, lm)
 Brightness: a subjective descriptor, difficult to measure

10
Human Perception of Color
Two Types of Photoreceptors at Retina
• Rods
• Long and thin
• Large quantity (~ 100 million)
• Provide scotopic vision (i.e., dim light vision or at low illumination)
• Only extract luminance information and provide a general overall
picture
• Cones
• Short and thick, densely packed in fovea (center of retina)
• Much fewer (~7 million) and less sensitive to light than rods
• Provide photopic vision (i.e., bright light vision or at high illumination)
• Help resolve fine details as each cone is connected to its own nerve end
• Responsible for color vision

Our focus in this lecture, sensors of eye responsible for color


11
Human Perception of Color
Absorption of light by the red, green,
and blue cones in the human eye as a
function of wavelength.
7 millions cones in a human eye
• 65% sensitive to Red light
• 33% sensitive to Green light
• 2 % sensitive to Blue light

Primary colors: Defined CIE in 1931


• Red = 700 nm
• Green = 546.1nm
• Blue = 435.8 nm

CIE = Commission Internationale de l’Eclairage (The


International Commission on Illumination)
12
Digital Image Processing, by Gonzalez and Woods, Pearson, 2018.
CIE Standard 1931

Yellow
CIE 1931:Primary Colors:
Red (700nm)
Cyan magenta Green (546.1nm)
Blue (435.8nm)

Mixtures of Light

• Colors can be seen as combinations of 3 primary colors: R, G, B


13
Primary and Secondary Colors

Mixtures of Light Mixtures of Pigments


LCD monitor Color printing

14
Color Characterization
• Brightness
• brightness embodies the achromatic notion of intensity
• Hue
• hue represents dominant color as perceived by an observer
• specify color tone (redness, greenness, etc.)
• depend on peak wavelength
• Saturation
• the relative purity or the amount of white light mixed with a hue
• describe how pure the color is
• depend on the spread (bandwidth) of light spectrum
Hue
• reflect how much white light is added Chromaticity
Saturation
15
CIE Chromaticity Diagram
• Color can be viewed as a mixture of
primary colors
• Tristimulus value: amount of red green
blue to form any color (X, Y, Z)
• Color can be specified by its trichromatic
value (x, y, z)
Specify color by using
X chromaticity diagram
x=
X +Y + Z y=62% green x=25% red
Y z=13% blue
y=
X +Y + Z
Z
z=
X +Y + Z
Points on the boundary are
x + y + z =1 fully saturated colors 16
Example: Seeing Yellow without Yellow

570nm
520nm 630nm

Mix green and red light to obtain perception of yellow, without


shining a single yellow photon.
17
Color Image Processing
We will cover:
• Color Fundamentals
• Color Models
• RGB, CMY and CMYK, HSI
• Color Image processing
• Pseudo color image processing
• Full color image processing
• Full Color Image Processing
• Color transformations
• Color image smoothing and sharpening
• Color image segmentation
• Noise in color models
18
Color Models
• The color model (color space or color system) is to facilitate the
specification of colors in some standards.
• Color model is a specification of a coordinate system and a
subspace within the system where a color is represented.
• RGB model: color monitors and video cameras.
• CMY and CMYK model: color printing.
• HSI model: Decouples color and grayscale (intensity), similar to human.

There are numerous color models in use today. Model conversion is required.
19
RGB Color Model
RGB color model: Based on the cartesian coordinate system

Schematic of RGB color cube. Points along the main diagonal have gray values,
from black at the origin to white at point (1, 1, 1). 20
RGB Color Model

Pixel depth:
Number of bits used to represent each pixel.

R = 8 bits Pixel depth 24 bits


G = 8 bits = 16,777,216 possible colors
B = 8 bits
(28 )3 = 16,777,216
21
RGB Color Model
𝑹𝑹 = 𝟏𝟏𝟏𝟏𝟏𝟏

Generating the RGB image


Three hidden surface planes
of the cross-sectional color
plane (127, G, B).

22
Image Represented by RGB Models

Images represented in the


RGB color model consist of
three component images,
one for each primary color.

23
CMY and CMYK Color Models
• Primary colors for pigment
• CMY – Cyan, Magenta, Yellow
– Complementary to RGB
– Proper mix of them produces black

• CMYK – Cyan, Magenta, Yellow, Black


– The conversion from CMY to CMYK begins by letting
K=min(C,M,Y)
– If K=1, C=M=Y=0,
– Otherwise:

24
HSI Color Model
RGB, CMY models are not good for human interpreting. HSI color model decouples
color and grayscale (intensity).

HSI Color model:


• Hue: Dominant color which describes the pure color
Color carrying
• Saturation: Relative purity (inversely proportional to amount of
information
white light added)

• Intensity: Brightness is a subjective descriptor and difficult to


measure

25
Example: HSI Components of RGB Cube

RGB Cube

Hue Saturation Intensity 26


Example: HSI Components of RGB Colors
RGB
Image Hue

Saturation Intensity

27
Example: Manipulating HSI Components

RGB image Hue Saturation Intensity 28


Color Image Processing
We will cover:
• Color Fundamentals
• Color Models
• RGB, CMY and CMYK, HSI
• Color Image processing
• Pseudo color image processing
• Full color image processing
• Full Color Image Processing
• Color transformations
• Color image smoothing and sharpening
• Color image segmentation
• Noise in color models
29
Color Image Processing

There are two types of color image processes:

• Pseudocolor image process: Assigning colors to gray values based on a


specific criterion. Gray scale images to be processed may be a single
image or multiple images such as multispectral images.

• Full color image process: The process to manipulate real color images
such as color photographs.

30
Pseudo Color Image Processing
Pseudo color = false color : In some case there is no “color” concept for a gray scale
image but we can assign “false” colors to an image.
Why we need to assign colors to gray scale image?

Answer: Human can distinguish different colors better than different shades of gray
(visualization and interpretation of grayscale images ).

31
Intensity Slicing and Color Coding

where 𝑐𝑐𝑘𝑘 is the color associated with the


kth intensity interval 𝐼𝐼𝑘𝑘 , defined by the
planes at l = k − 1 and l = k.

Illustration for intensity-slicing technique.

32
Intensity Slicing and Color Coding

Illustration for intensity-slicing technique. An alternative representation of


intensity-slicing technique.
33
Intensity Slicing Example

An X-ray image of a weld with cracks.

After assigning a yellow color to pixels with


value 255 and a blue color to all other pixels.

34
Multi-level Intensity Slicing
g(x, y) = Ck for lk −1 < f ( x, y) ≤ lk

Ck = Color No. k
lk = Threshold level k
Color

Ck
Ck-1

C3

C2
C1
0 l1 l2 l3 lk-1 lk
L-1
Intensity 35
Intensity Slicing Example

Grayscale image of the Picker Thyroid Result of intensity slicing using eight colors.
Phantom (a radiation test pattern).

36
Intensity Slicing and Color Coding

Grayscale image representing average monthly Result of color coding.


>20 rainfall.

Gray Color
Scale 10 map

37
Intensity to Color Transformations

Red component

More general than


intensity slicing. Green component

Blue component

Diagram of intensity to color transformation.


Images are fed into the corresponding red, green, and blue
inputs of an RGB color monitor.
38
Intensity to Color Transformations
Highlighting explosives in X-ray images

Pseudocolor enhancement using Transformation functions.


gray level to color transformations.
39
Intensity to Color Transformations
Combining several
grayscale images into a
single-color composite,
e.g., multispectral image
processing.

40
Multi-spectral Images

41
Intensity to Color Transformations

Red (R), green (G),


blue (B), and near-
infrared (IR)
components of a
R (0.63-0.69 𝜇𝜇𝜇𝜇) G(0.52-0.60 𝜇𝜇𝜇𝜇) B (0.45-0.52 𝜇𝜇𝜇𝜇)
Max-water penetration
LANDSAT
Vegetation Plant vigor
multispectral image
of the Washington,
D.C. area.

IR(0.76-0.90 𝜇𝜇𝜇𝜇)
Biomass and shoreline mapping
IR+G+B R+IR+B
42
Intensity to Color Transformations
Image/video colorization with deep learning: Using deep learning to learn a complicate
transformation function considering context.

https://richzhang.github.io/colorization/ https://github.com/ChenyangLEI/automatic-video-colorization

43
Color Image Processing
We will cover:
• Color Fundamentals
• Color Models
• RGB, CMY and CMYK, HSI
• Color Image processing
• Pseudo color image processing
• Full color image processing
• Full Color Image Processing
• Color transformations
• Color image smoothing and sharpening
• Color image segmentation
• Noise in Color models
44
Basics of Full-color Image Processing
Methods:

• Per-color-component processing: process each component separately.

Example of per-color-component processing: smoothing an image by smoothing


each RGB component separately.

Each pixel as a vector

45
Color Transformations
• Formulation:
𝑔𝑔(𝑥𝑥, 𝑦𝑦) = 𝑇𝑇[𝑓𝑓(𝑥𝑥, 𝑦𝑦)]

𝑓𝑓 𝑥𝑥, 𝑦𝑦 = input color image, 𝑔𝑔 𝑥𝑥, 𝑦𝑦 = output color image


𝑇𝑇 operation on 𝑓𝑓 over a spatial neighborhood of (x,y)

• Processing the components of a color image within the context of a single-color model.
Number of components
𝑠𝑠𝑖𝑖 = 𝑇𝑇𝑖𝑖 𝑟𝑟𝑖𝑖 , 𝑖𝑖 = 1,2, … , 𝑛𝑛

where 𝑟𝑟𝑖𝑖 = color component of 𝑓𝑓(𝑥𝑥, 𝑦𝑦) For RGB images, n = 3


𝑠𝑠𝑖𝑖 = color component of 𝑔𝑔(𝑥𝑥, 𝑦𝑦)
46
Color Space Components

A full-color image
Full Color Cyan Magenta Yellow and its various
color-space
components.

Cyan Magenta Yellow Black


47
Color Space Components

A full-color image
and its various
Red Green Blue color-space
components.

Hue Saturation Intensity


48
Colour Slicing Transformation
• One of the simplest ways to “slice” a color image is to map the colors
outside some range of interest into a nonprominent neutral color.
Prototypical color center with components (𝑎𝑎_1, 𝑎𝑎_2,…, 𝑎𝑎_𝑛𝑛)

Set to gray
Set to gray

Keep the original


Keep the original
color
color

Cube based Sphere based

49
Example: Color Slicing Transformation
After color slicing

Original image

50
Histogram Equalization of a Full-color Image
• Histogram equalization of a color image can be performed by adjusting color
intensity uniformly while leaving color unchanged.

• The HSI model is suitable for histogram equalization where only Intensity (I)
component is equalized. 𝑘𝑘

𝑠𝑠𝑘𝑘 = 𝑇𝑇 𝑟𝑟𝑘𝑘 = (𝐿𝐿 − 1) � 𝑝𝑝𝑟𝑟 (𝑟𝑟𝑗𝑗 )


𝑗𝑗=0
𝑘𝑘
𝑛𝑛𝑗𝑗
= (𝐿𝐿 − 1) �
𝑀𝑀𝑁𝑁
𝑗𝑗=0

where 𝑟𝑟 and 𝑠𝑠 are intensity components of input and output color image.

51
Histogram Equalization of a Full-color Image
Original image

After histogram After increasing


equalization saturation component

52
Color Image Smoothing
Image smoothing by neighborhood averaging:
Two methods:
• Per-color-plane method: for RGB, CMY
color models, Smooth each color plane
using moving averaging and combine back
to RGB;
• Smooth only Intensity component of a HSI
image while leaving H and S unmodified.
Note: two methods are not equivalent.

53
Color Image Smoothing Example

Color image Red

Green
Blue

54
Color Image Smoothing Example

Color image

HSI Components

Hue Saturation Intensity

55
Color Image Smoothing Example

Smooth all RGB components Smooth only I component of HSI (faster) Differences

56
Color Image Sharpening
Image sharpening using the Laplacian:

We can do the same manner as color image smoothing:


• Per-color-plane method for RGB, CMY images
• Sharpening only I component of a HSI image

57
Color Image Sharpening Example

Sharpening all RGB components Sharpening only I component of HSI Differences

58
Color Image Segmentation
Methods
• Segmented in HSI color space:
A thresholding function based on color information in H and S Components.
We rarely use I component for color image segmentation.

• Segmentation in RGB vector space:


A thresholding function based on distance in a color vector space.

59
Color Segmentation in HSI Color Space
Color image Hue

1 2

3 4
Saturation Intensity
60
Color Segmentation in HSI Color Space
Binary thresholding of S component Product of 2 and 5
with T = 10%

5 6

Red pixels

7 8
Histogram of 6 Segmentation of red color pixels 61
Color Segmentation in HSI Color Space

Color image Segmented results of red pixels

62
Color Segmentation in RGB Vector Space

• Each point with (R,G,B) coordinate in the vector space represents one color.
• Segmentation is based on distance thresholding in a vector space.

1 if D(c(x, y), cT ) ≤ T
g(x, y) = 
0 if D(c(x, y), cT ) > T
cT = color to be segmented.
D(u,v) = distance function c(x,y) = RGB vector at pixel (x,y).
63
Example: Segmentation in RGB Color Space

Color image

Reference color cT to be
𝑇𝑇 =average color of pixel in the box
𝑐𝑐segmented

Results of segmentation in RGB vector


space with Threshold values
T = 1.25 times the SD of R,G,B values in the box

64
Noise in Color Images

RGB
(corrupted by
additive + +
Gaussian noise)

R G B

HSI Noise is less noticeable


in a color image

H S I
65
Noise in Color Images

RGB image with green Hue component Saturation component Intensity component
channel corrupted by
salt-and-pepper noise

66
Color Image Processing
We will cover:
• Color Fundamentals
• Color Models
• RGB, CMY and CMYK, HSI
• Color Image processing
• Pseudo color image processing
• Full color image processing
• Full Color Image Processing
• Color transformations
• Color image smoothing and sharpening
• Color image segmentation
• Noise in color models
67

You might also like