Professional Documents
Culture Documents
YC
b
C
r
= Luminance, Blue, Red (compression)
...
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 2/49
Image size
An image is a multi-dimensional object
YC
b
C
r
= Luminance, Blue, Red (compression)
...
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 2/49
Image size
An image is a multi-dimensional object
YC
b
C
r
= Luminance, Blue, Red (compression)
...
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 2/49
Spatial resolution
Resolution is not size
Resolution is a measure of the smallest detail visible:
higher resolution = more detail
Unit of measure
Resolution only makes sense if you have a unit of measure (e.g. mm)
Common units of resolution
, y
i =0
3
j =0
a
ij
x
i
y
j
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 9/49
Dierent interpolation methods
Nearest neighbor
Use the intensity value of the nearest pixel in the original image
Bilinear interpolation
Use information from the four nearest neighbors
F(x
, y
i =0
3
j =0
a
ij
x
i
y
j
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 9/49
Dierent interpolation methods
Nearest neighbor
Use the intensity value of the nearest pixel in the original image
Bilinear interpolation
Use information from the four nearest neighbors
F(x
, y
i =0
3
j =0
a
ij
x
i
y
j
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 9/49
(c) 4x4 grid (d) 4x4 and 12x12 grid
(e) Nearest neighbor (f) Bilinear (g) Bicubic
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 10/49
Interpolation examples
(h) 64x64 (i) 128x128 N.Neigh.
(j) 128x128 Bilin. (k) 128x128 Bicub.
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 11/49
Interpolation examples
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 12/49
Pixel neighbors
4-neighborhood
Given a pixel p = I (x, y), the 4-neighbors are
N
4
(p) = {I (x + 1, y), I (x 1, y), I (x, y + 1), , I (x, y 1)}
Note
If the p is on the border of the image some of the neighbors will be
outside of the image
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 13/49
Pixel neighbors
Diagonal-neighborhood
Given a pixel p = I (x, y), the diagonal-neighbors are
N
D
(p) = {I (x + 1, y + 1), I (x + 1, y 1), I (x 1, y + 1), , I (x 1, y 1)}
Note
If the p is on the border of the image some of the neighbors will be
outside of the image
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 14/49
Pixel neighbors
8-neighborhood
The 8-neighborhood is given by
N
8
(p) = N
4
N
D
Note
If the p is on the border of the image some of the neighbors will be
outside of the image
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 15/49
Adjacency
4-adjacency
Given two pixels p = 0, q = 0 they are 4-adjacent if
q N
4
(p) or p N
4
(q)
8-adjacency
Given two pixels p = 0, q = 0 they are 8-adjacent if
q N
8
(p) = p N
8
(q)
m-adjacency
Given two pixels p = 0, q = 0 they are m-adjacent if
q N
4
(p), or
q N
D
(p) and all pixels in N
4
(p) N
4
(q) are zero
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 16/49
Paths (curves)
Denition
A path from a pixel p = (x, y) to a pixel q = (s, t) is
a sequence of adjacent pixels {(x
0
, y
0
), (x
1
, y
1
), ..., (x
n
, y
n
)} such that
(x
0
, y
0
) = (x, y) and (x
n
, y
n
) = (s, t)
Closed path
A path is closed if (x, y) = (x
0
, y
0
) = (x
n
, y
n
) = (s, t)
4- 8- and m-paths
D(p, q) 0
D(p, q) = D(q, p)
(p
x
q
x
)
2
+ (p
y
q
y
)
2
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 21/49
Distance measures
Denition
A function D(p, q), where p and q are points in an image, is called a
distance function or distance metric if all the following conditions are
veried
D(p, q) 0
D(p, q) = D(q, p)
(p
x
q
x
)
2
+ (p
y
q
y
)
2
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 21/49
Distance measures
D
4
distance (alias Manhattan or city block)
Given p = (p
x
, p
y
) and q = (q
x
, q
y
) the Manhattan distance is
D
4
(p, q) = |p
x
q
x
| +|p
y
q
y
|
D
8
distance (alias chessboard)
Given p = I (p
x
, p
y
) and q = I (q
x
, q
y
) the chessboard distance is
D
8
(p, q) = max(|p
x
q
x
|, |p
y
q
y
|)
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 22/49
Distance measures
D
4
distance (alias Manhattan or city block)
Given p = (p
x
, p
y
) and q = (q
x
, q
y
) the Manhattan distance is
D
4
(p, q) = |p
x
q
x
| +|p
y
q
y
|
D
8
distance (alias chessboard)
Given p = I (p
x
, p
y
) and q = I (q
x
, q
y
) the chessboard distance is
D
8
(p, q) = max(|p
x
q
x
|, |p
y
q
y
|)
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 22/49
Matrix vs Array (point by point) operations
Given two matrices a =
a
1,1
a
1,2
a
2,1
a
2,2
and b =
b
1,1
b
1,2
b
2,1
b
2,2
Array product
The array product of a and b is
ab =
a
1,1
a
1,2
a
2,1
a
2,2
b
1,1
b
1,2
b
2,1
b
2,2
a
1,1
b
1,1
a
1,2
b
1,2
a
2,1
b
2,1
a
2,2
b
2,2
Matrix product
The matrix product of a and b is
ab =
a
1,1
a
1,2
a
2,1
a
2,2
b
1,1
b
1,2
b
2,1
b
2,2
a
1,1
b
1,1
+ a
1,2
b
2,1
a
1,1
b
1,2
+ a
1,2
b
2,2
a
2,1
b
1,1
+ a
2,2
b
2,1
a
2,1
b
1,2
+ a
2,2
b
2,2
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 23/49
Matrix vs Array (point by point) operations
Given two matrices a =
a
1,1
a
1,2
a
2,1
a
2,2
and b =
b
1,1
b
1,2
b
2,1
b
2,2
Array product
The array product of a and b is
ab =
a
1,1
a
1,2
a
2,1
a
2,2
b
1,1
b
1,2
b
2,1
b
2,2
a
1,1
b
1,1
a
1,2
b
1,2
a
2,1
b
2,1
a
2,2
b
2,2
Matrix product
The matrix product of a and b is
ab =
a
1,1
a
1,2
a
2,1
a
2,2
b
1,1
b
1,2
b
2,1
b
2,2
a
1,1
b
1,1
+ a
1,2
b
2,1
a
1,1
b
1,2
+ a
1,2
b
2,2
a
2,1
b
1,1
+ a
2,2
b
2,1
a
2,1
b
1,2
+ a
2,2
b
2,2
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 23/49
Linear vs Non-linear operations
Consider operator H such that, given the image f (x, y) as input, it
produces the image g(x, y) as output
H [f (x, y)] = g(x, y)
Linear operations
H is said to be a linear operator if it satises the additivity property, i.e.
H [a
i
f
i
(x, y) + a
j
f
j
(x, y)] = [a
i
f
i
(x, y)] + [a
j
f
j
(x, y)]
= a
i
g
i
(x, y) + a
j
g
j
(x, y)
Non-linear operations
H is said to be a non-linear operator if the additivity property is not
satised
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 24/49
Linear vs Non-linear operations
Consider operator H such that, given the image f (x, y) as input, it
produces the image g(x, y) as output
H [f (x, y)] = g(x, y)
Linear operations
H is said to be a linear operator if it satises the additivity property, i.e.
H [a
i
f
i
(x, y) + a
j
f
j
(x, y)] = [a
i
f
i
(x, y)] + [a
j
f
j
(x, y)]
= a
i
g
i
(x, y) + a
j
g
j
(x, y)
Non-linear operations
H is said to be a non-linear operator if the additivity property is not
satised
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 24/49
Linear vs Non-linear operations
Consider operator H such that, given the image f (x, y) as input, it
produces the image g(x, y) as output
H [f (x, y)] = g(x, y)
Linear operations
H is said to be a linear operator if it satises the additivity property, i.e.
H [a
i
f
i
(x, y) + a
j
f
j
(x, y)] = [a
i
f
i
(x, y)] + [a
j
f
j
(x, y)]
= a
i
g
i
(x, y) + a
j
g
j
(x, y)
Non-linear operations
H is said to be a non-linear operator if the additivity property is not
satised
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 24/49
Arithmetic Operations
Denition
Arithmetic operations between images are array operations and they can
be written as
s(x, y) = f (x, y) + g(x, y)
d(x, y) = f (x, y) g(x, y)
p(x, y) = f (x, y) g(x, y)
v(x, y) = f (x, y) g(x, y)
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 25/49
Arithmetic Operations
Denition
Arithmetic operations between images are array operations and they can
be written as
s(x, y) = f (x, y) + g(x, y)
d(x, y) = f (x, y) g(x, y)
p(x, y) = f (x, y) g(x, y)
v(x, y) = f (x, y) g(x, y)
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 25/49
Frequent use of image summation: image denoising
Assumptions
Suppose that we have a clean image f (x, y) and some non-correlated
noise (x, y), then g(x, y) = f (x, y) +(x, y) is a noise corrupted image.
Average
If we have multiple noisy images g
i
(x, y), we can obtain f (x, y) by using
the average operation
g(x, y) =
1
K
K
i =1
g
i
(x, y)
Then
E { g(x, y)} = f (x, y)
2
g(x,y)
=
1
K
2
(x,y)
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 26/49
Frequent use of image summation: image denoising
Assumptions
Suppose that we have a clean image f (x, y) and some non-correlated
noise (x, y), then g(x, y) = f (x, y) +(x, y) is a noise corrupted image.
Average
If we have multiple noisy images g
i
(x, y), we can obtain f (x, y) by using
the average operation
g(x, y) =
1
K
K
i =1
g
i
(x, y)
Then
E { g(x, y)} = f (x, y)
2
g(x,y)
=
1
K
2
(x,y)
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 26/49
Image averaging example
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 27/49
Frequent use of image subtraction: visibility enhancement
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 28/49
Frequent use of image multiplication (division): shading
correction
Description
Sometimes the lighting in a scene may be non-uniform, or the camera
lens may present the vignetting phenomenon. This can be easily
corrected if we can model the shading pattern.
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 29/49
Note on data range
Data range problem
The usual data range for 8-bit images is [0, 255]. If we perform
arithmetics on such images, we may end up with values outside that
range (i.e. 15 200 = 175)
Data range solution
After performing arithmetics you should do the following
f
m
= f min(f )
f
s
= K
f
m
max(f
m
)
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 30/49
Note on data precision
Data precision problem
Especially when performing division, you might want better precision
than available by using integer operations.
Data precision solution
1. Convert the data to oating-point
2. Perform arithmetics
3. Convert the data back to integer
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 31/49
Sets
Denition
A set is a collection of elements and it is indicated by a list of all
elements, or a specication of the element characteristics, e.g.
A = {1, 2, 4, 7, 10, 52}
A = {w|w = 2k + 1}
Set membership
If an element a is in set A, then we write
a A
Similarly, if a is not in set A, then we write
a / A
The empty set is denoted by the symbol
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 32/49
Sets
Denition
A set is a collection of elements and it is indicated by a list of all
elements, or a specication of the element characteristics, e.g.
A = {1, 2, 4, 7, 10, 52}
A = {w|w = 2k + 1}
Set membership
If an element a is in set A, then we write
a A
Similarly, if a is not in set A, then we write
a / A
The empty set is denoted by the symbol
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 32/49
Set operations
Union and intersection
The union of sets A and B is
W = A B = {w A or w B}
The intersection of sets A and B is
W = A B = {w A and w B}
Complement and dierence
The complement of a set A is
A
C
= {w|w / A}
The dierence between two sets A and B is
A B = {w A, w / B} = A B
C
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 33/49
Set operations
Union and intersection
The union of sets A and B is
W = A B = {w A or w B}
The intersection of sets A and B is
W = A B = {w A and w B}
Complement and dierence
The complement of a set A is
A
C
= {w|w / A}
The dierence between two sets A and B is
A B = {w A, w / B} = A B
C
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 33/49
Logical operations
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 34/49
Spatial operations
Spatial (image space) operations are divided in three kinds
Single pixel
Neighborhood
Single pixel
Neighborhood
Translation
Rotation
Scaling
Shearing
The ane transform has the following form
x y 1
v w 1
T =
v w 1
t
1,1
t
1,2
0
t
2,1
t
2,2
0
t
3,1
t
3,2
1
where x = vt
1,1
+ wt
2,1
+ t
3,1
and y = vt
1,2
+ wt
2,2
+ t
3,2
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 39/49
Geometric spatial transformations
Ane transform
The ane transform is a kind of generic transform that can perform
the following operations at the same time
Translation
Rotation
Scaling
Shearing
The ane transform has the following form
x y 1
v w 1
T =
v w 1
t
1,1
t
1,2
0
t
2,1
t
2,2
0
t
3,1
t
3,2
1
where x = vt
1,1
+ wt
2,1
+ t
3,1
and y = vt
1,2
+ wt
2,2
+ t
3,2
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 39/49
Ane transform usage
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 40/49
Image registration
Denition
Image registration is that process that allows to compute the
transformation (usually ane) that separates two images. It is used in
panorama stitching, super-resolution, etc...
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 41/49
Vector and matrix operations
A pixel with multiple values is a vector
Imagine a pixel with red, green and blue values: we can write it as
z =
r
g
b
z
1
z
2
z
3
(a
1
b
1
)
2
+ (a
2
b
2
)
2
+ (a
n
b
n
)
2
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 42/49
Vector and matrix operations
A pixel with multiple values is a vector
Imagine a pixel with red, green and blue values: we can write it as
z =
r
g
b
z
1
z
2
z
3
(a
1
b
1
)
2
+ (a
2
b
2
)
2
+ (a
n
b
n
)
2
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 42/49
Vector and matrix operations
A pixel with multiple values is a vector
Imagine a pixel with red, green and blue values: we can write it as
z =
r
g
b
z
1
z
2
z
3
(a
1
b
1
)
2
+ (a
2
b
2
)
2
+ (a
n
b
n
)
2
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 42/49
Vector and matrix operations
Linear transformations
When using matrix notation it is very easy to express linear
transformations
w = A(b a)
where A has size m n and w, a, b are all column vectors of size n 1
Image as a vector
Another useful representation of an image is that of a MN 1 vector
(assuming one color channel) where each row is a group of N elements of
the vector. Many linear transformations can then be expressed as
g = Hh +n
where H has size MN MN and represents the linear process, f is a
MN 1 vector representing the input image, n is a MN 1 vector
representing noise and g is the output image in vector form. all column
vectors of size n 1
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 43/49
Vector and matrix operations
Linear transformations
When using matrix notation it is very easy to express linear
transformations
w = A(b a)
where A has size m n and w, a, b are all column vectors of size n 1
Image as a vector
Another useful representation of an image is that of a MN 1 vector
(assuming one color channel) where each row is a group of N elements of
the vector. Many linear transformations can then be expressed as
g = Hh +n
where H has size MN MN and represents the linear process, f is a
MN 1 vector representing the input image, n is a MN 1 vector
representing noise and g is the output image in vector form. all column
vectors of size n 1
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 43/49
Space transforms
Going into outer space...
There are many dierent space in which image analysis can be
performed. The most well known is the Fourier space, which lies in the
frequency domain instead of the spatial domain.
Foorward T(u, v) transforms
A particular class of 2D linear transforms, known as T(u, v) can be
expressed as
T(u, v) =
M1
x=0
N1
y=0
f (x, y)r (x, y, u, v)
where f (x, y) is the input image, r (x, y, u, v) is called the forward
transformation kernel and 0 u M 1, 0 v N 1. u, v are called
the tranform variables.
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 44/49
Space transforms
Inverse T(u, v) transforms
f (x, y) =
M1
x=0
N1
y=0
T(u, v)s(x, y, u, v)
where s(x, y, u, v) is called the inverse transformation kernel and
0 u M 1, 0 v N 1.
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 45/49
Separable and symmetric transforms
Separable kernel
A kernel is said to be separable if
r (x, y, u, v) = r
1
(x, u)r
2
(y, v)
Symmetric kernel
A separable kernel is said to be symmetric if
r (x, y, u, v) = r
1
(x, u)r
1
(y, v)
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 46/49
Fourier Transform
Forward transform
r (x, y, u, v) = e
i 2(
ux
M
+
vy
N
)
Reverse transform
s(x, y, u, v) =
1
MN
e
i 2(
ux
M
+
vy
N
)
i or j
The book (written by an engineer) uses the letter j to indicate
1, but
I will use the letter i , because it is traditional to mathematics.
Other transforms
There are many other transforms expressed in such form as the Walsh,
Hadamard, Haar, discrete cosine, etc...
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 47/49
Probabilistic methods
Probability of an intensity value in an image
p(z
k
) =
n
k
MN
where z
k
is the k-th intensity level in the image, n
k
is the number of
pixels with intensity k and MN is the total number of pixels.
Sum of probabilities
L
k=1
p(z
k
) = 1
where L is the number of possible levels
Image average (mean): rst moment
m =
L
k=1
z
k
p(z
k
)
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 48/49
Probabilistic methods
Image variance: second moment
2
=
L
k=1
(z
k
m)
2
p(z
k
)
n-th statistical moment
n
(z) =
L
k=1
(z
k
m)
n
p(z
k
)
M. Fierro, Daegu Catholic University Digital Image Processing, Digital imaging fundamentals 49/49