Professional Documents
Culture Documents
Topics Covered:
Matlab orientation and refreshment
Review of linear algebra and linear systems
Image transformations
Image enhancement in spatial and frequency domains
Image restoration and segmentation
Advanced topics in medical applications
Numerical Analysis
Mathematical Methods
Basic statistics
Chapter 2
170 m
Optical Illusions
How accurately can we estimate and compare distances and areas?
By which features can we detect and distinguish objects?
http://www.michaelbach.de/ot/
Signal Sampling in 1D
Triangular grid
Hexagonal grid
Matrix Representation
j
FN N
f11
f
21
...
f i1
...
f N 1
f12
f 22
...
fi 2
...
fN2
...
...
...
...
...
...
f1 j
f2 j
...
f ij
...
f Nj
Neighborhood Relations
Indexing in 2D and 3D
...
...
...
...
...
...
f1N
f 2 N
...
f iN
...
f NN
Spatial Resolution
Question:
FOV=10mx20m
4 and 8 neighbors
6, 18, 26 neighbors
170 m
Y(n)
Linear Operator
T{X(n)} = Y(n)
X1(n)
Y1(n)
T{X1(n)} = Y1(n)
X2(n)
Y2(n)
T{X2(n)} = Y2(n)
Brightness Intensity.
Brightness Intensity.
Contrast Dynamic range
SNR Signal to noise ratio
The definitions of contrast and SNR may be
different in different areas.
Question:
High brightness but low contrast, examples?
SNR
avg ( signal )
std (background )
Signal Averaging
Signal Averaging
g ( x , y ) f ( x, y ) n ( x , y )
g ( x, y )
g ( x, y ) f ( x, y )
SNR
1 N
g i ( x, y )
N i 1
2signal
avg ( signal )
std (background )
signal
Signal Averaging
Image interpolation
Requirements:
Uncorrelated and zero mean noise
Registered images
52
39
Questions:
16
39
16
28 27
10
14
14
Inverse Problem
52
28 27
10
Image Interpolation
Interpolation is model based.
Optimized interpolation exists.
Commonly used interpolation methods:
N
Nearest
t neighbor
i hb
Linear, bilinear, trilinear
Cubic, bicubic, tricublic
Spline, many variations
Order of continuous
Nearest
neighbor
Linear
Cubic
Sampling vs Interpolation
Sampling means that all information is lost except at the
grid points. (continuous discrete)
Interpolation is to fill the gap between discrete grids.
(discrete continuous)
Affine Transformation
Geometric Transformation
Spatial transformation of coordinates
Intensity interpolation
Affine Transformation
Translation
Rotation
Scaling
Sheering
Translate
Rotate
Scale
Sheer
Rigid Body
Affine Transformation in 3D
Affine Transformation
x1 a11
y a
2 21
Translation
Rotation
Scaling
Sheering
Translate
a12 x t1
a22 y t2
x1 1 0 x t1 x t1
y 0 1 y t y t
2
2
2
x1 cos() sin() x 0
y sin() cos() y 0
2
Rotate
Rigid Body
Affine Transformation
x1 a11 a12 x t1
y a
2 21 a22 y t 2
Translate
Rotate
Affine Transformation
x1 a11
y a
2 21
a12 x t1
a22 y t2
Sheer
x1 1
y s
2 y
sX x x sX y
1 y y s y x
Scale
x1 s X
y 0
2
0 x s X x
s y y s y y
Scaling
x1 1 0 x t1 x t1
y 2 0 1 y t 2 y t 2
x1 cos() sin() x 0
y sin() cos() y 0
2
a12
a22
0
t1 x
t 2 y
1 1
x1
y1 1 x
t1 x
t 2 y
1 1
a11
y 1a21
t1
a12
a22
t2
0
0
1
Implementation
3D Affine Transformation
x1 a11 a12 a13 t1 x
y1 a 21 a 22 a 23 t 2 y
z1 a31 a32 a33 t 3 z
0
0
1 1
1 0
Implementation
Inverse mapping
F
Forward
d mapping
i
Nearest Neighbor
Linear
Cubic
Marker
Cost functions
Cross Correlation
Mutual Information
Intensity Transformation
Gray level mapping
Intensity Transformation
Lookup Table
Input
0
1
2
180
255
Intensity Transformation
255
Output
0
1
1
221
255
Transformation
function T(r)
L = 256
255
Image Negative
Log Transformation
L-1
Purpose: Spreading/compressing
a narrow range of the low
intensity values in the input image
into a wider range of intensities
s =c*log(1+ r)
c is a constant
L-1
s c(r )
c = 1,
= 1, 3, 4
255
0
threshold
255
255
negative
255
255
255
log
255
255
=2
Bit Planes
Original
10
Steganography
Removing all but the two least significant bits of each color component
produces an almost completely black image. Making that image 85 times
brighter produces the image on the right side.
http://en.wikipedia.org/wiki/Steganography
11
Histogram
Histogram Processing
Histogram
What is a histogram?
A discrete function h(rk) = nk where rk is the kth intensity value
and nk is the number of pixels in the image with intensity rk.
Normalized histogram
p(rk) = nk/(total pixels), k = 0,1,2,,L-1
p(rk) ~ the probability of occurrence of intensity level rk in an
image.
sum(p(rk)) = 1
Normalized Histogram
Assuming that we are using a normalized histogram
s=T(r) and that 0<= r <=1
s is the output grey scale for every pixel with value r in input
image
Let pr(r) and ps(s) denote the Probability Density Function (PDF) of
the random variables r and s respectively.
Given pr(r) and T(r), if T(r) is continuous and differentiable, the PDF
of the transformed variable s
ddr
p s ( s ) pr ( r )
ds
The PDF of the transformed variable, s, is determined by the PDF of
the input image and on the transformation function
s T (r ) ( L 1) pr (t )dt
0
12
p s ( s ) pr ( r )
dr
ds
Histogram Equalization
r
s T (r ) ( L 1) pr (t )dt
0
ds dT (r )
d r
( L 1) pr (t )dt ( L 1) pr (r )
d
dr
d
dr
d 0
dr
p s ( s ) pr ( r )
Histogram
Equalization
1
1
dr
pr ( r )
ds
( L 1) pr (r ) L 1
Histogram of the input image
Histogram Equalization
sk T ( rk ) ( L 1) pr ( ri )
i 0
L 1 k
ni
MN i 0
k 0,1,2,..., L 1
Input histogram
Qualitative
Dark image
Input images
Quantitative
Histogram
Equalized
Output histogram
Histogram
Dark image
Light image
Light image
Low contrast
Low contrast
High contrast
Transformation function
High contrast
13
http://en.wikipedia.org/wiki/Histogram_equalization
http://en.wikipedia.org/wiki/Histogram_equalization
Histogram Specification
Histogram Specification
Local Histogram Processing
Histogram Specification
pr(r): Input images PDF
pz(z): specified or desired PDF for output
r
s T (r ) pr (t )dt
0
Define:
Histogram Specification
Procedure
Calculate T(r) -- input histogram
Calculate G(z) desired histogram
Obtain
Ob i G-11 -- transformation
f
i ffunction
i
G ( z ) p z (t )dt s
0
G ( z ) T (r )
z G 1 ( s) G 1[T (r )]
14
Histogram Specification
Discrete formulation
Requirement:
pz(zi) != 0
sk T (rk ) pr (ri )
Why?
i 0
k
vk G ( z k ) p z ( z i ) s k
i 0
zk G 1[T (rk )] G 1 ( sk )
How to implement
sk zk?
original
equalized
specified
original
global
local
15
g ( x , y ) w ( 1, 1) f ( x 1, y 1) w ( 1,0 ) f ( x 1, y ) ...
w ( 0,0 ) f ( x , y ) ... w (1,1) f ( x 1, y1)
Simplified Notation
g ( x , y ) w ( 1, 1) f ( x 1, y 1) w ( 1,0 ) f ( x 1, y ) ...
R w1 z1 w2 z 2 ... wmn z mn
R w1 z1 w 2 z 2 ... w9 z 9
wT z
Median Filter
Purpose: remove salt and pepper noise
Operation: replace the centre pixel with the
neighborhood median
A nonlinear filter
filter, based on the ranking of pixels in a
kernel
8
8 2 5 5 4 6 7 8 9
Sort
2 4 5 5 6 7 8 8 9
16
Averaging Filter
Purpose: remove high frequencies from the image
(smoothing or blurring)
Operation: Assign the average value of a kernel to the
center of a neighborhood
The size of kernel controls the smoothing effect
R = min(zk | k=1,,9)
Predefined percentage
X-Ray image
8 2 5 5 4 6 7 8 9
Average: 6
Weighted Average
Gaussian Kernel
g ( x, y )
w(s, t ) f ( x s, y t )
s 1t 1
w(s, t )
s 1t 1
17
Kernel Size
1x1
3x3
9x9
5x5
35 x 35
15 x 15
15 x 15 averaging
kernel
Thresholding
Image Sharpening
Operators for sharpening: derivative operator which is
proportional to the degree of intensity discontinuity.
Image Sharpening
Finite Difference
Finite Difference
How to compute
x-1
x+1
f
x
f
f ( x 1) f ( x) =
x
f
f ( x) f ( x 1) =
Backward difference:
x
f
1
1
Central difference:
f (x ) f (x ) =
x
2
2
F
Forward
d diff
difference:
18
Accuracy
Finite Difference
32
38
56
x+1
f
f ( x 1) f ( x) =
x
f
f ( x) f ( x 1) =
Backward difference:
x
f
1
1
Central difference:
f (x ) f (x ) =
x
2
2
f
x
F
Forward
d diff
difference:
Finite Difference
32
38
56
How to compute
x-1
x+1
Central difference:
2 f
x 2
?
Distance
Velocity
Acceleration
2 f
f ( x 1) f ( x 1) 2 f ( x)
x 2
=
- 2x
Use the central difference formula for the first derivative and apply a
central difference formula for the derivative of f' at x.
2 f
x 2
Observations
First-order derivative
Horizontal segments zero
Onset of step or ramp nonzero
Ramp
R
with
i h constant slope
l
nonzero
Second-order derivative
Horizontal segments zero
Onset of step or ramp nonzero
Ramp with constant slope zero
Laplacian Filter
Rosnefeld and Kak (1982) introduced Laplacian filter to
image processing
Second derivative operator
Isotropic
p operator:
p
spatial
p
invariant
2 f
y-1
2 f 2 f
x 2 y 2
2 f
f ( x 1) f ( x 1) 2 f ( x )
x 2
y
y+1
x-1
x+1
2 f
f ( y 1) f ( y 1) 2 f ( y )
y 2
19
Laplacian Filter
y-1
y
y+1
y+1
x-1
x+1
x-1
f f
f ( x 1, y ) f ( x 1, y )
x 2
y 2
f ( x , y 1) f ( x , y 1) 4 f ( x , y )
2 f
Laplacian Filter
y-1
Laplacian Filter
x+1
2 f 2 f
f ( x 1, y 1) f ( x 1, y 1)
x 2
y 2
f ( x 1, y 1) f ( x 1, y 1) 4 f ( x , y )
2 f
Isotropic results
for increments of
90 degrees
Isotropic results
for increments of
45 degrees
Alternatives:
Unsharp Masking
Widely used in printing and publishing industries for
image sharpening
Laplacian without
scaling
Laplacian with
scaling (Set min
scaling.
to zero to raise all
values above
zero).
Use D4 sharpen
kernel
Use D8 sharpen
kernel with
additional
differentiation in
the diagonal
directions.
Method:
Blur the original image
Subtract the blurred image from the original. The result
difference image called the mask
Add the mask to the original image
20
Unsharp Masking
Highboost Filtering
g mask ( x , y ) f ( x , y ) f ( x , y )
g ( x, y ) f ( x, y ) k g mask ( x, y )
Original
Gaussian blurred
unsharp masking
highboost filtering
Mask
Point Detection
Point Detection
y-1
y
Point Detection
2 f 2 f
f ( x 1, y ) f ( x 1, y )
x 2 y 2
f ( x, y 1) f ( x, y 1) 4 f ( x, y )
2 f
y+1
x-1
x+1
21
Line Detection
Line Detection
What are the problems of using
the absolute value of Laplacian?
Line Detection
Apply +45
degree line
detector mask
threshold
Gradient Filter
In 2D, The gradient of f at (x,y) is a two dimensional
vector
Gradient = 0.6
Gradient in 1D
grad ( f ) f ( x ) g x
f
x
ff
gx
grad ( f ) f ( x , y ) fx
g y
y
22
mag ( f ( x , y ))
g 2x g 2y
mag ( f ( x , y ))
g 2x g 2y
Approximation:
Approximation:
mag ( f ( x , y )) g x g y
Pros and cons of the approximation?
mag ( f ( x , y )) g x g y
Pros and cons of the approximation?
Fast computing, but lost isotropic property (only for 90 rotation)
Gradient Filtering
Robert proposed a way to
compute the gradient with cross
differences:
g x z9 z5
g y z8 z 6
f [( z 9 z 5 ) 2 ( z 8 z 6 ) 2 ]1 / 2
f z9 z 5 z8 z 6
Gradient Filtering
Prewitt Operator
g x ( z 7 z 8 z 9 ) ( z1 z 2 z 3 )
g y ( z 3 z 6 z 9 ) ( z1 z 4 z 7 )
f ( z 7 z 8 z 9 ) ( z1 z 2 z 3 )
( z 3 z 6 z 9 ) ( z1 z 4 z 7 )
Gradient Filtering
Sensitivity to Noise
Sobel Operator
g x ( z 7 2 z 8 z 9 ) ( z1 2 z 2 z 3 )
g y ( z 3 2 z 6 z 9 ) ( z1 2 z 4 z 7 )
f ( z 7 2 z 8 z 9 ) ( z1 2 z 2 z 3 )
The
Th 1st
1 t and
d2
2nd
dd
derivative
i ti
are sensitive to noise
Use smoothing to keep the
main changes
( z 3 2 z 6 z 9 ) ( z1 2 z 4 z 7 )
Sobel has better noise suppression characteristics
23
Sensitivity to Noise
The 1st and 2nd derivative are sensitive to noise
Use a blurring filter to eliminate details and thus
only keep the main changes
Sum of coefficients
is 0. Why?
Roberts
R
b t C
Cross
Gradient Operator
In an area of
constant intensity,
the response
should be 0.
Sobel Operator
Contact lens
Tree leaves
Masks for detecting horizontal and vertical edges
Sobel |gx|
Sobel |gy|
Sobel |gx|+|gy|
Masks for detecting diagonal edges
24
Smoothed
with 5x5
averaging
filter
Sobel |gx|
Sobel |gx||+|g
|gy|
S b l ||gy|
Sobel
Image
Sobel
diagonal
operators
Sobel x- gradient image
Laplacian
5x5 average
smoothing
Sobel
Mask
Affine transformation
Geometric modification
Operations:
O
ti
translation,
t
l ti
rotation,
t ti
scaling
li and
d
shearing
Techniques: operation multiplication,
interpolation
Original
Gamma
25
Intensity transformation
Gray level mapping
Operations: transformation function. Pixel by
pixel.
i l
Techniques: image negatives, threshold, log
transformation, gamma transformation,
piecewise-linear transformation
Histogram processing: histogram equalization
and specification, local histogram processing
Spatial filtering
A neighborhood or a kernel. (Kernel level)
A predefined operation
Operations:
Smoothing: averaging, median
Sharpening: Laplacian, Highboost, gradient
Edge detection: Laplacian, gradient
Techniques
Sliding window
Finite difference
26