Transcript chapter_6

Chapter 6
Color Image Processing
國立雲林科技大學 電子工程系
張傳育(Chuan-Yu Chang ) 博士
Office: ES 709
TEL: 05-5342601 ext. 4337
E-mail: [email protected]
Color Fundamentals

In 1666, Sir Isaac Newton

He discovered that when a beam of sunlight
passes through a glass prism, the emerging beam
of light is consists of a continuous spectrum of
colors ranging from violet to red.
2
Color Fundamentals (cont.)



Basically, humans and some other animals perceive in
an object are determined by the nature of the light
reflected from the object.
Visible light is composed of a relatively narrow band of
frequencies in the electromagnetic spectrum.
For humans, colors are seen as variable combinations
of the primary colors: red, green, and blue.
3
Color Fundamentals (cont.)
人眼椎狀體吸收之紅、
綠、藍光的波長函數
1931年國際照明組織
(CIE)指定三原色的波
長:
Blue:435.8nm
Green:546.1nm
Red:700nm
65%的椎狀體可感應到紅
光,33%可感應到綠光,
只有2%感應到藍光
4
Color Fundamentals (cont.)

For the purpose of standardization, the CIE (the
international Commission on Illumination)
designated in 1931 the following specific
wavelength values to the three primary colors:



Blue=435.8 nm, Green=546.1 nm, and Red=700 nm.
From Fig. 6.2 and 6.3 that no single color may be called
red, green , or blue.
Having three specific primary color wavelengths for the
purpose of standardization does not mean that these
three fixed RGB components acting alone can generate
all spectrum colors.
5
Color Fundamentals (cont.)

Primary and secondary colors of light and pigments

The primary colors can be added to produce the secondary
colors of light: magenta (R+B), cyan (G+B), yellow (R+G)
光的混合式採用加
成的方式
In colorants, a primary color is defined
as one that subtracts or absorbs a
primary color of light and reflects or
transmits the other two.
The primary colors of pigments are magenta, cyan, and yellow
6
Color Fundamentals (cont.)

The characteristics generally used to distinguish one
color from another are



Brightness embodies the chromatic notion of intensity.
Hue represents dominant color as perceived by an
observer.
Saturation is an attribute associated with the dominant
wavelength in a mixture of light waves.


Saturation refers to the relative purity or the amount of white
light mixed with a hue.
Hue and saturation taken together are called chromaticity,
therefore, a color may be characterized by its brightness
and chromaticity.
7
Color Fundamentals (cont.)


The amounts of red, green, and blue needed to form any
particular color are called the tri-stimulus values and are
denoted, X, Y, and Z.
A color is then specified by its tri-chromatic coefficients,
defined as
X
x
X Y  Z
Y
y
X Y  Z
Z
z
X Y  Z

It is noted from these equations that
x+y+z=1
(6.1-1)
(6.1-2)
(6.1-3)
(6.1-4)
8
Color Fundamentals (cont.)

The CIE chromaticity diagram





Which shows color composition as a function of x (red) and
y (green).
For any value of x and y, the corresponding value of z (blue)
is obtained from Eq.(6.1-4).
z = 1- ( x + y )
approximately 62% green, 25% red , and 13% blue content.
The positions of the various spectrum colors from violet at
380 nm to red at 780 nm are indicated around the
boundary of the tongue-shaped chromaticity diagram.
These are the pure colors shown in the spectrum of Fig.
6.2.
9
Color Fundamentals (cont.)

紅色點佔
25%
CIE色度圖
綠色點佔
62%
藍色點佔
13%
10
Color Fundamentals (cont.)
11
Color Models

The RGB Color Model
 Each color appears in its primary spectral components of red,
green, and blue.
 Images represented in the RGB color model consist of three
component images, one for each primary color.
 When fed into an RGB monitor, these three images combine on
the phosphor screen to produce a composite color image.
 The number of bits used to represent each pixel in RGB space is
called the pixel depth.

Full-color denote a 24-bit RGB color image
12
Color Models (cont.)

Example 6.1

Generating the hidden face planes and a cross
section of the RGB color cube.

Fig. 6.8 is a solid, composed of the 224=16777216
colors..
13
Color Models (cont.)

Example 6.1 (cont.)
 Acquiring a color image is basically
the process shown in Fig. 6.9 in
reverse.
 A color image can be acquired by
using three filters, sensitive to red,
green, and blue.
 When we view a color scene with a
monochrome camera equipped with
one of these filters, the result is a
monochrome image whose intensity
is proportional to the response of that
filter.
 Repeating this process with each
filter produces three monochrome
images that are RGB component
images of the color scene.
14
Color Models (cont.)

Safe RGB color, All-system-safe color, Safe Web
color, Safe browser color




Given the variety of systems in current use, it is of
considerable interest to have a subset of colors that are
likely to be reproduced faithfully, reasonably independently
of viewer hardware capabilities.
216 colors are common to most systems, these colors have
become the standard for safe colors.
Each of the 216 safe colors is formed from three RGB
values, each value can only be 0, 51, 102, 153, 204, or
255.
The values 000000 and FFFFFF represent black and white,
respectively.
15
Color Models (cont.)
16
Color Models (cont.)

The CMY color model

Cyan, magenta, and yellow are the secondary colors of
light

Most devices that deposit colored pigments on paper, such as
color printers and copiers, require CMY data input or perform
an RGB to CMY conversion internally.
 C  1  R 
 M   1  G 
    
 Y  1  B 


 R  1  C 
G   1   M 
    
 B  1  Y 
(6.2-1)
The assumptions is that all color values have been
normalized to range [0,1].
The CMYK color model

In order to produce true black, a fourth color black is added
17
Color Models (cont.)

The HSI Color Model





When humans view a color object, we describe it by its hue,
saturation, and brightness.
Hue is a color attribute that describes a pure color.
Saturation gives a measure of the degree to which a pure
color is diluted by white light.
Brightness is a subjective descriptor that is practically
impossible to measure. (所以用intensity來取代brightness)
HSI color model decouples the intensity component from
the color-carrying information (hue and saturation) in a
color image.
18
Color Models (cont.)

Conceptual relationships between the RGB and HIS
color models



The intensity is along the line joining the vertices (0,0,0)
and (1,1,1).
If we wanted to determine the intensity component of any
color point, we would simply pass a plane perpendicular to
the intensity axis and containing the point.
The intersection of the plane with the intensity axis would
give us a point with intensity value in the range [0,1].
The intensity axis joining the black
and white vertices is vertical
19
Color Models (cont.)


Fig. 12(b) shows a plane defined by three points
(black, white, and cyan)
All points contained in the plane segment defined by
the intensity axis and the boundaries of the cube
have the same hue.



All colors generated by three colors lie in the triangle
defined by those colors.
If two of those points are black and white and the third is a
color point, all points on the triangle would have the same
hue.
By rotating the shaded plane about the vertical intensity
axis, we would obtain different hues.
20
Color Models (cont.)




The HIS space is represented by a
vertical intensity axis and the locus
of color points that lie on planes
perpendicular
Looking at the cube (Fig. 12) down
its gray-scale axis, as shown in Fig.
6.13(a).
In this plane we see that the primary
colors are separated by 120°.
The hue of the point is determined
by an angle from some reference
point.


Usually an angle of 0° from the red
axis designates 0 hue, and the hue
increases countercolockwise from
there.
The saturation is the length of the
vector from the origin to the point.
21
Color Models (cont.): Converting colors
from RGB to HSI

The H component of each RGB
pixel is obtained by
 
H 
360 
if B  G
if B  G
with
1




R  G   R _ G 




2
  cos1 
1/ 2 
 R  G 2  R  B G  B  







The saturation component is given
by
3
min(R, G, B)
RG B
The intensity component is given
by
S  1

1
I  ( R  G  B)
3
The RGB values have been normalized to
range [0,1] and that angle is measured with
22
respect to the red axis of the HSI space.
Color Models (cont.): Converting colors
from HIS to RGB



Given values of HIS in the interval [0,1], we can
find the corresponding RGB values in the same
range.
The applicable equations depend on the values of
H.
There are three sectors of interest, corresponding
to the 120。 intervals in the separation of primaries
23
Color Models (cont.)

RG sector 0  H  120
 When H is in this sector, the RGB components are given
by

S cos H 
R  I 1 


 cos(60  H ) 

B  I (1  S )
GB sector 120  H  240
 If the given value of H is in this sector, we first subtract
120° from it.

H  H  120
Then the RGB components are
R  I (1  S )

G  3I  ( R  B)

S cos H 
G  I 1 


 cos(60  H ) 
B  3I  ( R  G)
BR sector 240  H  360
 If the given value of H is in this sector, we first subtract
240° from it.
H  H  240
G  I (1  S )

S cos H 
B  I 1 


 cos(60  H ) 
R  3I  (G  B)
24
Color Models (cont.)
Its most distinguishing feature is the discontinuity in value along 45
line in the front (red) plane of the cube.
Fig. 6.8影像
的Hue
Fig. 6.8影像
的saturation
Fig. 6.8影像
的intensity
25
Color Models (cont.)
RGB影像
saturation的成
分影像
Hue的成分影像
intensity的成分
影像
26
Color Models (cont.)
修改過的hue成
分影像
修改過的intensity成
分影像
修改過的saturation
成分影像
重建的RGB影像
27
Pseudocolor Image Processing



Pseudocolor image processing consists of assigning
colors to gray values based on a specified criterion.
The principal use of pseudocolor is for human
visualization and interpretation of gray-scale events
in an images or sequence of images.
Intensity Slicing


If an image is interpreted as a 3D function, the method can
be viewed as one of placing planes parallel to the
coordinate plane of the image;
Each plan then “slices” the function in the area of
intersection.
28
Pseudocolor Image Processing (cont.)







Let [0, L-1] represent the gray scale
Let level l0 represent black [f(x,y)=0]
Level lL-1 represent white [f(x,y)=L-1]
Suppose that P planes perpendicular to the intensity axis are
defined at levels l1, l2,…, lp
Assuming that 0<P<L-1
The P planes partition the gray scale into P+1 intervals, V1,
V2, …, VP+1
Gray-level to color assignments are made according to the
relation
f ( x, y)  ck
if f( x,y) Vk
where ck is the color associated with the k-th intensity interval
Vk.
29
Pseudocolor Image Processing (cont.)




Fig. 6.18 shows an example of using a plane at f(x,y)=li to slice
the image function into two levels.
If a different color is assigned to each side of the plane, any pixel
whose gray level is above the plane will be coded with one color,
and any pixel below the plane will be coded with the other.
Levels that lie on the plane itself may be arbitrarily assigned one
of the two colors.
The result is a two-color image whose relative appearance can
be controlled by moving the slicing plane up and down the graylevel axis.
30
Pseudocolor Image Processing (cont.)
Any input gray level is assigned
one of two colors, depending on
whether it is above or below the
value of li.
When more levels are used, the
mapping function takes on a
staircase form.
31
Pseudocolor Image Processing (cont.)

Example 6.3 Intensity Slicing
單色的甲狀腺影像
(monochrome image of the
Picker Thyroid Phantom )
The result of intensity slicing this
image into eight color regions.
32
Pseudocolor Image Processing (cont.)

Example 6.3 Intensity Slicing (cont.)
 Intensity slicing assumes a much more meaningful and useful
role when subdivision of the gray scale is based on physical
characteristics of the image.
 Fig. 6.21(a) shows an X-ray image of a weld containing several
cracks and porosities with graylevel of 255.
 If the exact values of gray levels one is looking for are known,
intensity slicing is a simple but powerful aid in visualization.
Cracks/porosities
33
Pseudocolor Image Processing (cont.)

Example 6.4 Use of color to highlight rainfall levels
影像灰階對應平均月降雨
量
指定色彩給灰階
色彩編碼後
的影像
放大南美洲
的色彩編碼
影像
34
Pseudocolor Image Processing (cont.)

Gray Level to Color Transformations



To perform three independent transformations on the gray
level of any input pixel.
The three results are then fed separately into the red,
green, and blue channels of a color television monitor.
These are transformations on the gray level values of an
image and are not functions of position.
35
Pseudocolor Image Processing (cont.)

Example 6.5


Fig. 6.24(a) shows two
monochrome images of
luggage obtained from
an airport X-ray
scanning system.
The purpose of this
example is to illustrate
the use of gray level to
color transformations to
obtain various degrees
of enhancement.
Ordinary
materials
塑膠炸藥(plastic
explosive)
36
Pseudocolor Image Processing (cont.)






Fig 6.25 shows the transformation
functions used.
These sinusoidal functions contain
regions of relatively constant value
around the peaks and regions that
change rapidly near the valleys.
Changing the phase and frequency of
each sinusoid can emphasize (in color)
ranged in the gray scale.
If all three transformations have the
same phase and frequency, the output
image will be monochrome.
Fig. 6.24(b) was obtained with the
transformation functions in Fig. 6.25 (a).
Fig. 6.24(c) was obtained with the
transformation functions in Fig. 6.25 (b).
37
Pseudocolor Image Processing (cont.)

Combine several monochrome images into a
single color composite.


Usually used in Multispectral image processing
Different sensors produce individual monochrome
images, each in a different spectral band.
38
Pseudocolor Image Processing (cont.)
Red component
of an RGB
image
Blue
component of
an RGB image
Green
component of
an RGB image
Near-infrared
image
Red+Green+Blue
Green+Blue+Nearinfrared image
39
Pseudocolor Image Processing (cont.)
Jupiter moon Io
木星Io衛星影像
Surrounding yellow
materials are older
sulfur deposits
黃色的區域表示硫磺
的沉積物質
Bright red depicts
material newly
ejected from an
active volcano
紅色的區域表示活火
山新噴出的物質
40
Basic of Full-Color Image Processing

Full-color image processing approached fall into two
major categories:



Process each component image individually and then form
a composite processed color image from the individually
processed components.
Work with color pixels directly.
Let c represent an arbitrary vector in RGB color
space:
c R   R 
c  cG   G 
 c B   B 
 c R ( x, y )   R ( x, y ) 
c ( x, y )  cG ( x, y )   G ( x, y ) 
 c B ( x, y )   B ( x, y ) 
(6.4-1)
(6.4-2)
41
Basic of Full-Color Image Processing


The results of individual color component processing are not
always equivalent to direct processing in color vector space.
In order for per-color-component and vector-based processing to
be equivalent, two conditions have to be satisfied:


The process has to be applicable to both vectors and scalars.
The operations on each component of a vector must be independent
of the other components.
42
Color Transformation




Color transformation deal with processing the components of a color
image within the context of a single color model.
We model color transformations using the expression
g ( x, y)  T  f ( x, y)
where f(x,y) is a color input image, g(x,y) is the transformed color output
image, and T is an operator on f over a spatial neighborhood of (x,y).
The pixel values here are triplets or quartets from the color space
chosen to represent the images.
Color transformations
si  Ti (r1 , r2 ,..., rn ), i  1,2,..., n

(6.5-1)
(6.5-2)
ri and si are variables denoting the color components of f(x,y)and g(x,y) at
any point (x,y). n is the number of color components.
{T1, T2, …, Tn} is a set of color mapping function that operate on ri to
produce si.
n transformations, Ti, combine to implement the single transformation
function, T, in Eq(6.5-1).
43
Color Transformation (cont.)
A bowl of strawberries and cup of coffee
Strawberries are composed
of large amounts of magenta
and yellow.
CMYK成分,黑色代
表0,白色代表1。
草莓由大量的紅色
成分所組成。
Intensity成分 原始
影像的單色呈現
44
Color Transformation (cont.)

Suppose that we wish to modify the intensity of the image in
Fig. 6.30(a) using
g ( x, y)  kf ( x, y)

where 0<k<1.
In the HIS color space, this can be down with the simple
transformation
s3  kr3


where s1=r1, s2=r2。Only HIS intensity component r3 is modified.
In the RGB color space, three components must be
transformed:
si  kri i  1,2,3

The CMY space requires a similar set of linear transformations
si  kri  1  k  i  1,2,3
45
Color Transformation (cont.)

The result of applying any of the transformations
in Eq.(6.5-4)~ (6.5-6), using k=0.7
46
Color Complements


The hues directly opposite one another on
the color circle of Fig. 6.32 are called
complements.
Color complements are useful for enhancing
detail that is embedded in dark regions of a
color image.
47
Example 6.7
RGB的補色轉換
Identical to the gray-scale
negative transformation.
補色的轉換函數,
其中 飽和度S的
成分不變。
HSI的補色
轉換
48
Color Slicing

Color slicing


Highlighting a specific range of colors in an image is useful for
separating objects from their surroundings.
The basic idea is either to (將 ROI以外的色彩,映射到不重要的中
性色彩。)




Display the colors of interest so that they stand out from the
background
Use the region defined by the colors as a mask for further processing
To map the colors outside some range of interest to a nonprominent
neutral color. If the colors of interest are enclosed by a cube of
width W and centered at a prototypical color with components (a1,
a2, …, an) the necessary set of transformations is
Color Cube (hypercube)
W是立方體寬度,

W

中心成分在
0.5 if  r j  a j  
si  
2 1 j  n, i 1, 2,...,n

(a1,a2,…,an)
r
otherwise
 i
49
Color Slicing (cont.)

If a sphere is used to specify the colors of
interest, Eq. (6.5-7) becomes

0.5 if
si  
r
 i
2
 r j  a j 
n
j 1
 R02 , i  1,2,.., n
otherwise
R0是球體的半徑,
中心成分在
(a1,a2,…,an)
50
Example 6.8 An illustration of color slicing
W=0.2549,中心在(0.6863,
0.1608, 0.1922)的 RGB
cube
Radius=0.1765,中心在
(0.6863, 0.1608, 0.1922)的
RGB sphere
51
Tone and Color Corrections

色調與色彩之修正(Tone and color corrections)

Device-independent color model


建立螢幕和輸出裝置以及其裝置之間的色彩範圍
Color management system (CMS)


選擇採用CIE L*a*b*模型,或是CIELAB
CIE L*a*b*具有下列特性:



Colormetric
Perceptually uniform
Device independent
52
Tone and Color Corrections (cont.)

L*a*b* color model
 Y
L*  116 h
 YW

  16


  X
a*  500h
  X W
  Y
  h
 Y
  W




  Y
b*  200h
  YW
where
  Z
  h
 Z
  W




Xw, YW, Zw是白色的三色激
勵值(由圖6.5的 CIE色調圖
上x=0.3127, y=0.3290所
定義)
3 q

q  0.008856
hq   
7.787q  16 / 116 q  0.008856
53
Tone and Color Corrections (cont.)

色調範圍 (tonal range) ,亦稱為(key type)是
指影像色彩強度的一般分布。

High-key


Low-key


影像的大部分資訊集中於高(或亮)的強度
影像的大部分資訊集中於低(或暗)的強度
Middle-key

影像的大部分資訊介於high-key和low-key之間
54
Example 6.9 Tonal transformations
55
Example 6.10 Color balancing
56
Histogram Processing
57
Smoothing and Sharpening

Color Image Smoothing

The average of the RGB component vectors in the
neighborhood is
1
c ( x, y) 
cx, y 

K ( x , y )S xy

對每個顏色分量進行smooth
1

R x, y 


K
  x , y S xy

1



c  x, y   
G
x
,
y


K

x
,
y


S
xy


1



B
x
,
y

K

  x , y S xy


Smoothing by neighborhood averaging can be carried out
on a per-color-plane basis.
58
Example 6.12 Color image smoothing by
neighborhood averaging
Red
component
image
Original
RGB
image
Green
component
image
Blue
component
image
59
Example 6.12 Color image smoothing by
neighborhood averaging (cont.)
Hue
component
image
Saturation
component
image
Intensity
component
image
60
Example 6.12 Color image smoothing by
neighborhood averaging (cont.)
Image smoothing with 5x5 averaging mask
Result of
processing each
RGB component
image
Result of
processing Intensity
component image
Difference between
the two results
61
Smoothing and Sharpening (cont.)

Color Image Sharpening

Computing the Laplacian of each component image
separately.
 2 R  x, y 


 2 c x, y    2G  x, y 
 2 B  x, y 


62
Color Segmentation

Segmentation in HIS color Space



Color is represented in the hue image.
Saturation is used as a masking image to isolate
further regions of interest in the hue image.
Intensity image is used less frequency for
segmentation of color image because it carries no
color information.
63
Example 6.14 Segmentation in HIS space
Original
image
Saturation
image
對飽和影像取臨界
值(最大值的10%)
所得的遮罩影像,
將大於臨界值的像
素點設為1,其餘
設為黑色。
乘積影像的
histogram。
Hue image
Intensity
image
遮罩影像和Hue
影像的乘積。
對乘積影像取臨
界值(90%) ,後
所得之影像。
64
Color Segmentation (cont.)

Segmentation in RGB Vector Space



The objective is to segment objects of a specified color
range in an RGB image.
Let the average color be denoted by the RGB vector a.
The objective of segmentation is to classify each RGB pixel
in a given image as having a color in the specified range or
not.
D z , a   z  a

 z

 z  a  z  a 
T
1
2
R  a R    zG  aG    z B  a B 
2
2
2

65
Example 6.15 Color image segmentation
in RGB space
66
Color Segmentation (cont.)

Color Edge Detection
67
Chapter 6
Color Image Processing
68
Example 6.16 Edge detection in vector space
69
Example 6.16 Edge detection in vector space
(cont.)
Red component的
gradient
Green component的
gradient
Blue component的
gradient
70
Noise in Color Image
71
Example 6.17 Illustration of the effects of
converting noisy RGB images to HSI
72
Example 6.17 Illustration of the effects of
converting noisy RGB images to HIS (cont.)
73
Example 6.17 Illustration of the effects of
converting noisy RGB images to HIS (cont.)
74
Example 6.18 A color image compression
example
75