Document

(2) Fundamentals
- Sources of images: computer graphics, scanners, digital cameras,
digital video recorder…
- Image formation process
Light
Object
Image plane
Lens
z
Optical axis
f: focal length
•: World point (X, Y, Z)
(x, y): Image
coordinate
y (X, Y, Z): the world coordinate of a point on the object
y (x, y): a point on the image plane (through perspective projection)
y Image plane: an array of charged coupled devices (CCD)
* Every device is a picture element (pixel, pel, pxl)
2-1
* The detected value of the CCD at location (x, y) is the pixel value at
location (x, y) in the image
* The dimension of the array determines the number of pixels, e.g.,
256×256 = 65,536 pixels
y Resolution: number of dots/pixels per inch (dpi)
* E.g.: printing a 512×512 image with 300 dpi: size of printout =
4.33×4.33 cm (512×2.54/300 = 4.33); with 600 dpi: 2.17×2.17 cm
(a) Image representation
- Image types
y Bit-mapped image: composed of pixels
Æ E.g., Photoshop: resizing the image causes deformation (see
supplement: circle.jpg)
y Vector-based image: graphical objects represented using
mathematical formula
Æ E.g., Illustrator: resizing the image will not cause deformation (see
2-2
supplement: circle.doc)
- Pixel values are represented by a 2D function:
f(x, y) = i(x, y) ⋅ r(x, y)
Image size: M×N
0 ≤ x < M, 0 ≤ y < N
MATLAB: 1 ≤ x ≤ M, 1 ≤ y ≤ N
(0, 0)
x, c
f(x, y),
f(c, r)
y, r
(x, y)
(M–1, N–1)
y f: intensity, 0 < f < ∞
y i: illumination, determined by the light source, 0 < i < ∞
y r: reflectance, determined by the characteristics of the object surface,
0 < r <1 (0: total absorption, 1: total reflection)
- Binary image: f(x, y) = a or b
Æ Only two values for a pixel: may be represented by 1 bit (0 or 1)
y Size of a 256×256 image file: 65,536 bits = 8,192 bytes
2-3
1
1
1
1
0
0
1
1
1
0
0
0
1
1
1
0
0
0
1
1
0
0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
- Gray level image: 0 ≤ f(x, y) ≤ 255
Æ A pixel value is represented by 1 byte (28); 0~255: from black to
white (256 levels)
y Size of a 256×256 image file: 65,536 bytes
147 135 116 104
72
54
141 129 113
90
66
56
138 126 104
82
74
121
137 119
99
166 210
98
131 118 150 197 219 206
157 192 214 210 198 186
2-4
- Color models of color images
y RGB model: red, green, and blue primaries
Original image
Red component
Green component
Blue component
* According to mixtures of light (additive primaries, e.g., monitors,
projectors)
* Number of representable colors: (28)3 = 224 = 16,777,216 (true color)
* E.g., (0, 255, 0): green, (255, 0, 0): red, (0, 120, 0): light green, (100, 100,
0): yellow
y CMYK model: cyan (green+blue), magenta (red+blue), yellow
(red+green), and black (K)
* According to mixtures of pigments (subtractive primaries, e.g., printers)
Æ Four-color printing (no mixture for black color)
2-5
* Conversion from RGB to CMYK:
# First normalize RGB values to range [0, 1]
 C  1  R 
 M  = 1 − G 
    
 Y  1  B 
RGB
CMYK
y HSI (or HSB) model: Hue, Saturation, and Intensity (or Brightness)
* Hue: color attribute that describes a pure color (yellow, orange, or red)
* Saturation: the degree to which a pure color is diluted by white light
* Intensity: light intensity (0%: black, 100%: white)
* Conversion from RGB to HSI (normalized RGB):
2-6
r=
R
B
G
b
=
g
=
( R + G + B) ,
( R + G + B)
( R + G + B ) , and
y YIQ model: standard for color TV broadcasting
* Conversion from RGB to YIQ:
Y  0.299 0.587 0.114  R 
 I  = 0.596 − 0.275 − 0.321 G 
  
 
Q  0.212 − 0.523 0.311  B 
y YCbCr model: luminance (Y) and two colors (Cb and Cr)
* Conversion from RGB to YCbCr:
Y = 0.299R + 0.587G + 0.114B
Cb = 0.5 + (B − Y)/2
Cr = 0.5 +(R − Y)/1.6
- Common image file format
y raw: only pixel values (no header)
y pgm: Portable Greymap Image
2-7
y tiff or tif: Tagged Image File Format
y jpeg or jpg: Joint Photographic Experts Group
y gif: Graphics Interchange Format
y png: Portable Network Graphic
y bmp: Bitmap
- Index-color file format
y Image file includes a header and pixel values
y Colors are recorded in a palette (or colormap) placed in the header
y Each image has its own palette and pixel values are index values
y E.g., the palette (RGB values normalized) and pixels of a 7×7 image:
Index
0
1
2
Color (RGB)
(0.62, 0.62, 0.22)
(0.11, 0.25, 0.15)
(0.12, 0.36, 0.75)
255
(0.46, 0.253, 0.77)
..
.
..
.
2 120
110 58
200 2
224 25
0
88
99 43
168 45
35
76
4
9
88
12
85
35 35 35 36
58 76 58 76
5
6
9
12
16 70 51 126
74 65
5
4
59 200 225 197
233 55 254 66
2-8
(b) Sampling and quantization
- To be suitable for computer processing, an image function f(x, y) must
be digitized spatially and in amplitude
- Image sampling: digitizing the spatial coordinates
Æ Partition the xy plane into a grid (integers)
256×256
64×64
32×32
- Gray-level quantization: quantizing the pixel values
Æ Quantize the real pixel values into discrete gray levels (integers)
y Greater number of gray levels: smooth change of colors; less number
of levels: sharp change of colors
2-9
256 levels
8 levels
4 levels
(c) Relationships between pixels
- Neighbors of a pixel p(x, y)
(x−1, y−1)
(x−1, y)
(x−1, y+1)
(x, y−1)
p(x, y)
(x, y+1)
(x+1, y−1)
(x+1, y)
(x+1, y+1)
y 4-neighbors (•): N4(p)
y Diagonal neighbors (D-neighbors, •): ND(p)
y 8-neighbors (• and •): N8(p)
2-10
- Connectivity: determines if two pixels are connected
y Two pixels, p and q, are connected if there is a path from p to q
y All connected pixels form a connected component
y 4-connectivity: pixels p and q are 4-connected Æ q ∈ N4(p)
y 8-connectivity: p and q are 8-connected Æ q ∈ N8(p)
y m-connectivity (mixed connectivity): p and q are m-connected if
* q ∈ N4(p), or
* q ∈ ND(p) and N4(p) ∩ N4(q) = ∅
Æ m-connectivity eliminates the multiple path connections for
8-connectivity
Multiple paths in 8-connectivity
Unique path in m-connectivity
y How many objects are there in the following image?
2-11
- Distance measures
Æ Measuring the distance between two pixels p(x, y) and q(s, t)
y Euclidean distance: De(p, q) = [(x–s)2 + (y–t)2]1/2
y City-block distance (D4 distance): D4(p, q) = |x–s| + |y–t|
y Chessboard distance (D8 distance): D8(p, q) = max(|x–s|, |y–t|)
D4:
2
2
1
2
2
1
0
1
2
D8: 2 2 2 2 2
2 1 1 1 2
2
1
2
2
2 1 0 1 2
2 1 1 1 2
2 2 2 2 2
2-12
(d) Imaging geometry
- Basic 2D transformations
y Translation: translate a point (X, Y) to a new location using
displacements (X0, Y0)
X * = X + X0
Y = Y + Y0
*
or
X 
*
 X  1 0 X 0   
Y
 *=


 Y  0 1 Y0   1 
 
or
 X *  1 0 X 0   X 
 * 
Y 
Y
Y
=
0
1
0 
  

 1  0 0 1   1 
 
X *
X 
1 0 X 0 
 *
*
Y 
0 1 Y 
*
v
Y
=
v
=
=
T
Æ v = Tv , where
,
,
and
0 
 
 

1 
 1 
0 0 1 
 
y Scaling: scale by factors Sx and Sy along the X and Y axes
 S x 0 0


Æ v* = Sv , where S =  0 S y 0
 0 0 1
y Rotation: rotate angle θ
2-13
Æ v* = Rv , where
 cos θ sin θ 0
R = − sin θ cos θ 0
 0
0 1
- Perspective transformations
x
λ
=
y
Y
X
=
and
(by triangulation)
λ λ−Z
λ−Z
Image plane
(X, Y, Z)
x, X
λ
z, Z
Lens center
(x, y)
y, Y
2-14