Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

IAP Chapter1 2012

Download as pdf or txt
Download as pdf or txt
You are on page 1of 66

Digital Image Processing

Dr.-Ing. Tuan Do-Hong


Department of Telecommunications Engineering
Faculty of Electrical and Electronics Engineering
HoChiMinh City University of Technology
E-mail: do-hong@hcmut.edu.vn

Dept. of Telecomm. Eng.


Faculty of EEE

DIP2012
DHT, HCMUT

Outline
1.

Digital Image Fundamentals

2.

Image Enhancement and Restoration

3.

Image Compression

4.

Morphological Image Processing

5.

Image Segmentation

6.

Image Representation and Description

7.

Introduction to Object (Pattern) Recognition

Dept. of Telecomm. Eng.


Faculty of EEE

DIP2012
DHT, HCMUT

References
[1] R. C. Gonzalez, R. E. Woods, Digital Image
Processing, Addison Wesley, 2nd edition (2002), 3rd
edition (2008).
[2] R. C. Gonzalez, R. E. Woods, S. L. Eddins, Digital
Image Processing Using Matlab, Gatesmark
Publishing, 2nd edition (2009)

Dept. of Telecomm. Eng.


Faculty of EEE

DIP2012
DHT, HCMUT

Chapter 1:
Digital Image Fundamentals

Dept. of Telecomm. Eng.


Faculty of EEE

DIP2012
DHT, HCMUT

1. Digital Image

Dept. of Telecomm. Eng.


Faculty of EEE

DIP2012
DHT, HCMUT

1. Analog to Digital (1)

Imaging
systems

object

observe

Sample and
quantize

Digital
storage
(disk)

Digital
computer

On-line
buffer

digitize

store

process

Refresh
/store

Dept. of Telecomm. Eng.


Faculty of EEE

Display output

Record

DIP2012
DHT, HCMUT

1. Analog to Digital (2)


Computers work with numerical (rather than pictorial) data.
An image must be converted to numerical form before processing by
computer.

Picture elements or pixels.


Rectangular sampling grid.
(Intensity) Brightness of the image.
Dept. of Telecomm. Eng.
Faculty of EEE

DIP2012
DHT, HCMUT

1. Sampling (Digitization of Spatial Coordinates)


256256

Dept. of Telecomm. Eng.


Faculty of EEE

6464

DIP2012
DHT, HCMUT

1. Quantization (Intensity Digitization) (1)


0

255

255

255

255

255

255

255

255

Dept. of Telecomm. Eng.


Faculty of EEE

DIP2012
DHT, HCMUT

1. Quantization (2)

256256, 256 gray-levels

Dept. of Telecomm. Eng.


Faculty of EEE

256256, 32 gray-levels

10

DIP2012
DHT, HCMUT

1. Quantization (3)
256256, 256 gray-levels

Dept. of Telecomm. Eng.


Faculty of EEE

256256, 2 gray-levels

11

DIP2012
DHT, HCMUT

1. Colour Image

Dept. of Telecomm. Eng.


Faculty of EEE

12

DIP2012
DHT, HCMUT

1. Gray-level Image

Dept. of Telecomm. Eng.


Faculty of EEE

13

DIP2012
DHT, HCMUT

1. Binary Image

Dept. of Telecomm. Eng.


Faculty of EEE

14

DIP2012
DHT, HCMUT

1. Digital Image Processing


Manipulation of multidimensional signals
Image (photo): f ( x, y )
Video: f ( x, y, t )
CT, MRI: f ( x, y, z, t )
Coding/compression
Enhancement, restoration, reconstruction
Analysis, detection, recognition, understanding
Visualization

Dept. of Telecomm. Eng.


Faculty of EEE

15

DIP2012
DHT, HCMUT

1. Image Transforms

Original Image

Dept. of Telecomm. Eng.


Faculty of EEE

Fourier Transform
Magnitude
Phase

16

DIP2012
DHT, HCMUT

1. Image Enhancement
High Pass Filtering

Original Image

Dept. of Telecomm. Eng.


Faculty of EEE

17

DIP2012
DHT, HCMUT

1. Image Compression

Encoder
g ( x, y )

f ( x, y )

Compressed
Representation

Decoder
g ( x, y )

Dept. of Telecomm. Eng.


Faculty of EEE

18

f ( x, y )

DIP2012
DHT, HCMUT

1. Image Analysis

Dept. of Telecomm. Eng.


Faculty of EEE

19

DIP2012
DHT, HCMUT

1. Applications
Image processing (medical image processing, satellite/astronomy
image processing, radar image processing, etc.)
Image analysis - computer vision (character/face/hand/gesture
recognitions, content-based browsing and retrieval, medical image
analysis, industrial automation, remote sensing, forensics, robotics,
radar imaging, cartography, etc.)
Virtual reality (applications in manufacturing, medicine,
entertainment, etc.)
Multimedia communication/storage (video processing, digital TV,
video over networks, etc.)

Dept. of Telecomm. Eng.


Faculty of EEE

20

DIP2012
DHT, HCMUT

1. Image Model
Image: 2-D light-intensity function, f(x,y): value of f at spatial
coordinates (x,y) gives intensity of image at that point.
(2.1)
0 < f ( x, y ) <
(2.2)
f ( x, y ) = i ( x, y ) r ( x, y )
where i(x,y): illumination (amount of source light incident on the
scene), r(x,y): reflectance (amount of light reflected by the objects in
the scene).
0 < i ( x, y ) <
(2.3)
0 < r ( x, y ) < 1
0 (total absorption), 1 (total reflectance)
In digital image processing, f called gray level G, Lmin < G < Lmax.
Interval [Lmin, Lmax]: gray scale.
In practice, shifting gray scale to [0, L], G = 0: black, G = L: white.
Dept. of Telecomm. Eng.
Faculty of EEE

21

DIP2012
DHT, HCMUT

1. Image Sampling & Quantization (1)


f(x,y) approximated by equally spaced samples in the form of (NM)matrix:
f (0,0)
f (1,0)
f ( x, y )

f ( N 1,0)

f (0,1)

f (1,1)

f ( N 1,1)

f (0, M 1)
f (1, M 1)
=A

f ( N 1, M 1)

(2.4)

Matrix A is called digital image, each element of A is called image


element, pixel, or pel.
Sampling: partitioning xy-plane into grid, coordinates of center of each
grid are (x,y); x,y: integer. Quantization: f is assigned a gray-level value
G (real or integer numbers).
In practice, N = 2n, M = 2k, G = 2m. Total number of bits required to
store a digital image: NMm
Resolution: degree of discernible detail (how good approximation in
(2.4)), depending on the number of samples (spatial resolution) and
gray-levels (intensity resolution).
Dept. of Telecomm. Eng.
Faculty of EEE

22

DIP2012
DHT, HCMUT

1. Image Sampling & Quantization (2)

Digitizing the
coordinate
values
Digitizing the
amplitude
values

Dept. of Telecomm. Eng.


Faculty of EEE

23

DIP2012
DHT, HCMUT

1. Image Sampling & Quantization (3)

Dept. of Telecomm. Eng.


Faculty of EEE

24

DIP2012
DHT, HCMUT

1. Image Sampling & Quantization (4)

Dept. of Telecomm. Eng.


Faculty of EEE

25

DIP2012
DHT, HCMUT

1. Image Sampling & Quantization (5)

Dept. of Telecomm. Eng.


Faculty of EEE

26

DIP2012
DHT, HCMUT

1. Image Sampling & Quantization (6)

Dept. of Telecomm. Eng.


Faculty of EEE

27

DIP2012
DHT, HCMUT

1. Image Sampling & Quantization (7)

Dept. of Telecomm. Eng.


Faculty of EEE

28

DIP2012
DHT, HCMUT

1. Image Interpolation
Interpolation: Process of using known data to estimate unknown values.
E.g., zooming, shrinking, rotating, and geometric correction.
Interpolation (sometimes called resampling): an imaging method to
increase (or decrease) the number of pixels in a digital image.
Some digital cameras use interpolation to produce a larger image than the
sensor captured or to create digital zoom
(http://www.dpreview.com/learn/?/key=interpolation)

Dept. of Telecomm. Eng.


Faculty of EEE

29

DIP2012
DHT, HCMUT

1. Relationships Between Pixels (1)


Neighbors of a pixel: consider a pixel p at (x,y)

o 4-neighbors of p, N4(p): neighbors at (x+1,y), (x-1,y), (x,y+1), (x,y-1).


o 4-diagonal neighbors of p, ND(p): (x+1,y+1), (x+1,y-1), (x-1,y+1),
(x-1,y-1).
o 8-neighbors of p, N8(p): N4(p) and ND(p).

Dept. of Telecomm. Eng.


Faculty of EEE

30

DIP2012
DHT, HCMUT

1. Relationships Between Pixels (2)


Connectivity: Two pixels are connected if they are adjacent (e.g. 4neighbors) and their gray levels satisfy specified criterion of similarity
(e.g. they are equal).
Let V set of gray levels used to define connectivity (e.g. V={1}: binary
image; V={32,33,,63,64}: gray-scale image).
4-connectivity (4-adjacent): p and q are 4-connected if their
values from V and q is in N4(p).
8-connectivity (8-adjacent): p and q are 8-connected if their
values from V and q is in N8(p).
m-connectivity (m-adjacent, mixed connectivity): p and q are mconnected if their values from V and
q is in N4(p), or
q is in ND(p) and set S=N4(p) N4(q) is empty (pixels S
are 4-neighbors of both p and q, and whose values are
from V).
Dept. of Telecomm. Eng.
Faculty of EEE

31

DIP2012
DHT, HCMUT

1. Relationships Between Pixels (3)


m-connectivity introduced to eliminate ambiguity in path
connections (resulted from allowing 8-connectivity)
0

8-neighbors of center pixel

Dept. of Telecomm. Eng.


Faculty of EEE

m-neighbors of center pixel

32

DIP2012
DHT, HCMUT

1. Relationships Between Pixels (4)


Path
A (digital) path (or curve) from pixel p with coordinates (x0, y0) to
pixel q with coordinates (xn, yn) is a sequence of distinct pixels
with coordinates:
(x0, y0), (x1, y1), , (xn, yn)
where (xi, yi) and (xi-1, yi-1) are adjacent for 1 i n. Here n is
the length of the path.
If (x0, y0) = (xn, yn), the path is closed path.
We can define 4-, 8-, and m-paths based on the type of
connectivity used.

Dept. of Telecomm. Eng.


Faculty of EEE

33

DIP2012
DHT, HCMUT

1. Relationships Between Pixels (5)


Examples: Connectivity and Path, V = {1, 2}

0 1 1
0 2 0
0 0 1
1,1

1,2

1,3

2,1

2,2

2,3

3,1

3,2

3,3

0 1 1
0 2 0
0 0 1

0 1 1
0 2 0
0 0 1

8-adjacent

m-adjacent

The 8-path from (1,3) to (3,3):


(i) (1,3), (1,2), (2,2), (3,3)
(ii) (1,3), (2,2), (3,3)

Dept. of Telecomm. Eng.


Faculty of EEE

The m-path from (1,3) to (3,3):


(1,3), (1,2), (2,2), (3,3)

34

DIP2012
DHT, HCMUT

1. Relationships Between Pixels (6)


Connected in S
Let S represent a subset of pixels in an image. Two pixels p with
coordinates (x0, y0) and q with coordinates (xn, yn) are said to be
connected in S if there exists a path:
(x0, y0), (x1, y1), , (xn, yn)
where i, 0 i n, ( xi , yi ) S
Let S represent a subset of pixels in an image
For every pixel p in S, the set of pixels in S that are connected to p
is called a connected component of S.
If S has only one connected component, then S is called
connected set.
We call R a region of the image if R is a connected set.
Two regions, Ri and Rj are said to be adjacent if their union forms
a connected set.
Regions that are not to be adjacent are said to be disjoint.
Dept. of Telecomm. Eng.
Faculty of EEE

35

DIP2012
DHT, HCMUT

1. Relationships Between Pixels (7)


Boundary (or border)
The boundary of the region R is the set of pixels in the region that
have one or more neighbors that are not in R.
If R happens to be an entire image, then its boundary is defined as
the set of pixels in the first and last rows and columns of the
image.
Foreground and background
An image contains K disjoint regions, Rk, k = 1, 2, , K. Let Ru denote
the union of all the K regions, and let (Ru)c denote its complement.
All the points in Ru is called foreground;
All the points in (Ru)c is called background.

Dept. of Telecomm. Eng.


Faculty of EEE

36

DIP2012
DHT, HCMUT

1. Relationships Between Pixels (8)


Distance measures
Given pixels p, q and z with coordinates (x, y), (s, t), (u, v)
respectively, the distance function D has following properties:
a. D(p, q) 0
[D(p, q) = 0, iff p = q]
b. D(p, q) = D(q, p)
c. D(p, z) D(p, q) + D(q, z)

The following are the different distance measures:


a. Euclidean distance:
De(p, q) = [(x - s)2 + (y - t)2]1/2
b. City block distance:
D4(p, q) = |x - s| + |y - t|
c. Chess board distance:
D8(p, q) = max(|x - s|, |y - t|)
Dept. of Telecomm. Eng.
Faculty of EEE

37

DIP2012
DHT, HCMUT

1. Relationships Between Pixels (9)


Array vs. Matrix operation

Array
product
operator

Matrix
product
operator

a11
A=
a21

a11b11
A .* B =
a21b21

a11b11 + a12b21
A*B=
a21b11 + a22b21

Dept. of Telecomm. Eng.


Faculty of EEE

b11 b12
B=

b21 b22

a12
a22

a12b12
a22b22

a11b12 + a12b22
a21b12 + a22b22

38

Array product

Matrix product

DIP2012
DHT, HCMUT

1. Relationships Between Pixels (10)


Linear vs. Nonlinear operation

H [ f ( x, y ) ] = g ( x, y )
H ai fi ( x, y ) + a j f j ( x, y )

Additivity

= H [ ai fi ( x, y ) ] + H a j f j ( x, y )
= ai H [ fi ( x, y ) ] + a j H f j ( x, y )

Homogeneity

= ai gi ( x, y ) + a j g j ( x, y )
H is said to be a linear operator;
H is said to be a nonlinear operator if it does not meet the above
qualification.

Dept. of Telecomm. Eng.


Faculty of EEE

39

DIP2012
DHT, HCMUT

1. Relationships Between Pixels (11)


Arithmetic operation
Arithmetic operations between 2 pixels p and q: addition,
subtraction, multiplication, division (carry out pixel by pixel).
Mask (window) operation:

p1 p2 p3

w1 w2 w3

p4 p5 p6

w4 w5 w6

p7 p8 p9

w7 w8 w9

p = wi pi p5
i =1

with proper selection of coefficients, the operation is used for noise


reduction, region thinning, edge detection.
Dept. of Telecomm. Eng.
Faculty of EEE

40

DIP2012
DHT, HCMUT

1. Relationships Between Pixels (12)


Example of average window:

Dept. of Telecomm. Eng.


Faculty of EEE

41

DIP2012
DHT, HCMUT

1. Relationships Between Pixels (13)


Set and Logical operations
Let A be the elements of a gray-scale image.
The elements of A are triplets of the form (x, y, z), where x and y are
spatial coordinates and z denotes the intensity at the point (x, y).
=
A {(=
x, y, z ) | z f ( x, y )}

The complement of A is denoted Ac


Ac =
{( x, y, K z ) | ( x, y, z ) A}
K= 2k 1; k is the number of intensity bits used to represent z

The union of two gray-scale images (sets) A and B is defined as the set:

=
A B {max(a, b) | a A, b B}
z

Dept. of Telecomm. Eng.


Faculty of EEE

42

DIP2012
DHT, HCMUT

1. Relationships Between Pixels (14)

Dept. of Telecomm. Eng.


Faculty of EEE

43

DIP2012
DHT, HCMUT

1. Relationships Between Pixels (15)

Dept. of Telecomm. Eng.


Faculty of EEE

44

DIP2012
DHT, HCMUT

1. Relationships Between Pixels (16)


Logic operations: used for feature detection, shape analysis, binary
image processing.

Dept. of Telecomm. Eng.


Faculty of EEE

45

DIP2012
DHT, HCMUT

1. Imaging Geometry (1)


Translation: A point (x, y, z) is shifted to new position at (x, y, z) by
using displacements (x0, y0, z0):

x' = x + x0
y ' = y + y0
z ' = z + z0

x' 1 0 0
y ' = 0 1 0

z ' 0 0 1

x
x0
y
y0
z
z0
1

x' 1
y ' 0
=
z ' 0

1 0

0 0
1 0
0 1
0 0

x0 x
y0 y
z0 z

1 1

Matrix form: v=Tv.


Scaling: by factors Sx, Sy, Sz along the x, y, z axes given by
S x
0
S=
0

Dept. of Telecomm. Eng.


Faculty of EEE

0
Sy
0
0

46

0
0
Sz
0

0
0
0

DIP2012
DHT, HCMUT

1. Imaging Geometry (2)


Rotation:
Rotation of a point about z-coordinate by an angle :
cos
sin
R =
0

sin
cos
0
0

0
0
1
0

0
0
0

Rotation of a point about x-coordinate by an angle :


0
1
0 cos
R =
0 sin

0
0

Dept. of Telecomm. Eng.


Faculty of EEE

47

0
sin
cos
0

0
0
0

DIP2012
DHT, HCMUT

1. Imaging Geometry (3)


Rotation of a point about y-coordinate by an angle :
cos
0
R =
sin

Dept. of Telecomm. Eng.


Faculty of EEE

0 sin
1

0
0

cos
0

48

0
0
0

DIP2012
DHT, HCMUT

1. Image Transforms: General Form

M 1

T (u , v) = r ( x, y, u , v) f ( x, y )
x =0

M 1 N 1

g ( x, y ) = s ( x, y, u , v) R[T (u, v)]


=
u 0=
v 0

Dept. of Telecomm. Eng.


Faculty of EEE

49

DIP2012
DHT, HCMUT

1. Image Transforms: 2-D Fourier Transform (1)


Definition:

M 1 N 1

1
F (u , v) =
MN

f ( x, y )e j 2 (ux / M + vy / N )

x =0 y =0

M 1 N 1

f ( x, y ) = F (u , v)e j 2 ( ux / M +vy / N )
u =0 v =0

Properties:
Separability:

1
F (u , v) =
N

N 1

( j 2ux / N )

x =0

N 1

f ( x, y )e ( j 2vy / N )

y =0

for u, v = 0, 1., N-1.

1
f ( x, y ) =
N

N 1

e
u =0

( j 2ux / N )

N 1

F (u, v)e(

j 2vy / N )

v =0

for x, y = 0, 1., N-1.


Dept. of Telecomm. Eng.
Faculty of EEE

50

DIP2012
DHT, HCMUT

1. Image Transforms: 2-D Fourier Transform (2)


Advantage of separability property: F(u,v) or f(x,y) can be
obtained in 2 steps by successive applications of the 1-D Fourier
transform or its inverse:

1
F (u , v) =
N
with

N 1

F ( x, v )e (

1
F ( x, v ) = N
N

j 2ux / N )

x =0

N 1

f ( x, y )e
y =0

( j 2vy / N )

Others: translation, periodicity and conjugate symmetry, rotation,


scaling.

Dept. of Telecomm. Eng.


Faculty of EEE

51

DIP2012
DHT, HCMUT

1. Image Transforms: 2-D Fourier Transform (3)


Examples of 2-D Fourier transform:

Original Image

Dept. of Telecomm. Eng.


Faculty of EEE

Magnitude of
Fourier transform

52

Phase of
Fourier transform

DIP2012
DHT, HCMUT

1. Image Transforms: 2-D Fourier Transform (4)

Magnitude
of Fourier
transform

Original
image

Reconstructed
image

Low pass
filter used

Dept. of Telecomm. Eng.


Faculty of EEE

53

DIP2012
DHT, HCMUT

1. Image Transforms: 2-D Fourier Transform (5)

High pass
filter used

Dept. of Telecomm. Eng.


Faculty of EEE

Reconstructed
image

54

DIP2012
DHT, HCMUT

1. Image Transforms: 2-D Fourier Transform (6)

Dept. of Telecomm. Eng.


Faculty of EEE

55

DIP2012
DHT, HCMUT

1. Image Transforms: 2-D DCT (1)


DCT (Discrete Cosine Transform):
(2 x + 1)u
(2 y + 1)v
C (u , v) = (u ) (v) f ( x, y ) cos
cos

2 N

2N
x =0 y =0
N 1 N 1

for u, v = 0, 1., N-1, and

(2 x + 1)u
(2 y + 1)v
f ( x, y ) = (u ) (v)C (u , v) cos
cos

2 N

2N
u =0 v =0
N 1 N 1

for x, y = 0, 1., N-1.


where

Dept. of Telecomm. Eng.


Faculty of EEE

1
,
u=0

(u ) = N
2 , u = 1,2,..., N 1
N
56

DIP2012
DHT, HCMUT

1. Image Transforms: 2-D DCT (2)


2-D general transform:
M 1 N 1

F (u , v) = T ( x, y, u , v) f ( x, y )
x =0 y =0

M 1 N 1

f ( x, y ) = I ( x, y, u , v) F (u , v)
u =0 v =0

where T(x,y,u,v) and I(x,y,u,v) are forward and inverse transform


kernel (basis functions), respectively. The basis function depends
only on the indexes u, v, x, y, not on the values of image or its
transform.

Dept. of Telecomm. Eng.


Faculty of EEE

57

DIP2012
DHT, HCMUT

1. Image Transforms: 2-D DCT (3)


Example of basis functions of 2-D DCT, N=4:
v

u
0

Dept. of Telecomm. Eng.


Faculty of EEE

58

DIP2012
DHT, HCMUT

1. Image Transforms: 2-D DCT (4)


Example of basis functions of 2-D DCT, N=8:

Dept. of Telecomm. Eng.


Faculty of EEE

59

DIP2012
DHT, HCMUT

1. Image Transforms: 2-D DCT (5)


DCT is a real transform.
There are fast algorithms to compute the DCT similar to the FFT.
DCT has excellent energy compaction properties.

Dept. of Telecomm. Eng.


Faculty of EEE

60

DIP2012
DHT, HCMUT

1. Image Transforms: 2-D DCT (6)

Dept. of Telecomm. Eng.


Faculty of EEE

61

DIP2012
DHT, HCMUT

1. Image Transforms: 2-D DCT (7)

Original

DCT
Dept. of Telecomm. Eng.
Faculty of EEE

FFT

62

DIP2012
DHT, HCMUT

1. Image Transforms: 2-D DCT (8)

Dept. of Telecomm. Eng.


Faculty of EEE

63

DIP2012
DHT, HCMUT

1. Image Transforms: 2-D DCT (9)

Original

Reconstructed from IDCT, (J < 5)

Reconstructed from IDCT, (J < 20)

Reconstructed from IDCT, (J < 10)


Dept. of Telecomm. Eng.
Faculty of EEE

64

DIP2012
DHT, HCMUT

1. Probabilistic Methods (1)


Let zi , i = 0, 1, 2, ..., L -1, denote the values of all possible intensities
in an M N digital image. The probability, p( zk ), of intensity level
zk occurring in a given image is estimated as
nk
,
MN
where nk is the number of times that intensity zk occurs in the image.
p ( zk ) =

L 1

p( z ) =1
k

k =0

The mean (average) intensity is given by


L 1

m=

z
k =0

p ( zk )

The variance of the intensities is given by


L 1

= ( z k m) 2 p ( z k )
2

k =0

Dept. of Telecomm. Eng.


Faculty of EEE

65

DIP2012
DHT, HCMUT

1. Probabilistic Methods (2)


The n th moment of the intensity variable z is
L 1

un ( z ) =

n
(
)
z

m
p ( zk )
k
k =0

Example: Comparison of standard deviation values

= 31.6

= 14.3
Dept. of Telecomm. Eng.
Faculty of EEE

= 31.6
66

= 49.2
DIP2012
DHT, HCMUT

You might also like