Chapter 2

advertisement
Chapter 2. Image Analysis
Image Analysis Domains
Frequency Domain
Spatial Domain
Image Algebra
• Addition
 Morphing
• Subtraction  Segmentation
• Multiplication by constant  brighter
• Division by constant
 darker
• AND  mask
• OR
 mask
• NOT  negative
Example
Image Geometry
• Scaling
• Translation
• Rotation
How to enlarge an image
(Scaling or Sampling)
• Zero-order hold (expand & duplicate)
• First-order hold (linear interpolation)
 Two methods
1. Expand rows, then expand columns
2. Extend with zeros, then perform convolution
process (support by hardware)
First Method (Method I)
8 4 8 
4 8 4


8 2 8 

8 6 4 6 8 
 4 6 8 6 4


8 5 2 5 8
8 6
6 6

6
 4

6 5.5
8 5
4
6
8
5
2
8
6 6
6 4

5.5 6
5 8
6
Convolution process
I [ x, y ]  i , j I [ x  i, y  j ]  M [i, j ]
Kernel or Mask
Convolution
First Order (method II)
8 4 8 
4 8 4


8 2 8 
0
0

0

0
0

0
0

0
0
0
0
0
8
0
4
0
0
0
4
0
8
0
0
0
8
0
4
0
0
0
0
0
8
0
2
0
8
0
0
0
0
0
0
0  1
0  4
 1
0  
2

0
1


0  4
0
1
2
1
1
2
1  8
4  6
1 
  4
2 
1  6
4  8
6
6
6
4
6
8
6
6
6
5.5
5
5.5
5
2
5
8
6
4

6
8 
How to reduce # of gray levels
(Quantization)
• Converting the lower bits to 0 via an AND
operation.
• Converting the lower bits to 1 via an OR
operation.
• Improved gray-scale (IGS) quantization
 remove false contour
• Variable bin size quantization
Example of
IGS
Example of IGS
Improved Gray-Scale (IGS)
Quantization
 IGS Quantization recognizes the eye’s
inherent sensitivity to edges and breaks them
up by adding to each pixel a random number,
which is generated from the low-order (Least
Significant Bits) of neighboring pixels.
An Example
A sum is formed from the current 8-bit gray-level value and the
four least significant bits of a previously generated sum. If the
four most significant bits of the current value are 1111, however,
0000 is added instead.
IGS Practice
Consider an 8-pixel line of gray-scale data,
{12, 12, 13, 13, 10, 13, 57, 54}, which has
been uniformly quantized with 6-bit
accuracy. Construct its 3-bit IGS
(Improved Gray-Scale) code.
Smoothing
Just like Integration
I [ x, y]  i , j I [ x  i, y  j ]
Image Filtering
• Linear filter
I [ x, y ]  i , j I [ x  i, y  j ]  M [i, j ]
• Non-linear filter
Image Smoothing
• Mean Filtering
• Gaussian Filtering
• Median Filtering
• Smoothing uniform regions
• Preserve edge structure
Mean Filtering Example
Gaussian
Filtering
Masks
Properties of smoothing masks
• The amount of smoothing and noise reduction is
proportional to the mask size.
• Step edges are blurred in proportion to the mask size.
Median
Filtering
Example
Example
Edge Detection
Just like Differentiation
df
f 2  f1

dx x2  x1
Detecting
Edges
Edge Detection Masks
Properties of derivative masks
• The sum of coordinates of derivative masks is zero so that a zero
response is obtained on constant regions.
• First derivative masks produce high absolute values at point of
high contrast.
• Second derivative masks produce zero-crossings at points of high
contrast.
Edge Magnitude & Orientation
Laplacian Of Gaussian (LOG)
Zero crossing detection
•
A zero crossing at a pixel implies that the values of the two
opposing neighboring pixels in some direction have different signs.
•
There four cases to test:
1. up/down
2. left/right
3. up-left/down-right
4. up-right/down-left
Two equivalent methods
1. Convolve the image with a Gaussian smoothing filter and compute
the Laplacian of the result.
2. Convolve the image with the linear filter that is the Laplacian of
the Gaussian filter.


h( x, y)   g ( x, y)  f ( x, y)   g ( x, y)  f ( x, y)
2
1
2
2
Gaussian Equations
Gaussian
Plots
Gaussian Properties
•
Symmetry matrix
•
95% of the total weight is contained within 2 of the center.
•
In the first derivative of 1D Gaussian, extreme points are
located at – and + .
•
In the second derivative of 1D Gaussian, zero crossings are
located at – and + .
•
The LOG filter responds well to:
1. small blobs coinciding with the center lobe.
2. large step edges very close to the center lobe.
LOG Masks
LOG Example
Frei-Chen Edge Detection
• Represent any 3x3 subimage as a weighted
sum of the nine Frei-Chen masks.
• Weights are found by projecting a 3x3
subimage onto each of these masks.
• The projection is performed through
convolution.
FreiChen
Masks
Projection of vectors
Since f1 , f2, … , f9 are nine 9D orthonormal vectors
I S  ( f I ) f1  ( f I ) f 2   ( f I ) f9
T
1 S
T
2 S
T
9 S
Errors in
Edge
Detection
Pratt Figure of Merit Rating Factor
•
•
•
•
•
IN = maximum(II , IF)
II = # of ideal edge points
IF = # of found edge points
α = a scaling constant to adjust the penalty for offset edges
di = the distance of a found edge point to an ideal edge point
1
R
IN
IF
1
 1  d
i 1
2
i
Noise Removal
Pepper & Salt Noise Reduction
• Change a pixel from 0 to 1 if all neighborhood pixels of the pixel is 1
• Change a pixel from 1 to 0 if all neighborhood pixels of the pixel is 0
Expanding & Shrinking
Example 1
Example 2
Image Segmentation
•
•
Region Based
•
Clustering
•
Region Growing
Edge based
•
Boundary Detection
Space of Clustering
• Histogram space  Thresholding
• Color space
 K-Means Clustering
• Spatial space
 Region Growing
Histogram & Thresholding
P-Tile Thresholding
Mode Thresholding
Mode Algorithm
Iterative Thresholding
Adaptive
Thresholding
Example
Adaptive Thresholding
Variable
Thresholding
Example
Double Thresholding Method
Double
Thresholding
Example
Recursive
Histogram
Clustering
Clustering
Iterative K-Means Clustering
Example of Region Growing
Region Growing
(Split & Merge Algorithm)
1. Split the image into equally sized regions.
2. Calculate the gray level variance for each region
3. If the gray level variance is larger than a threshold, then
split the region. Otherwise, an effort is made to merge the
region with its neighbors.
4. Repeat Step 2 & 3.
Gray level variance :
I (r , c)

I
N
Var ( I )   ( I ( r , c )  I ) 2
Boundary Detection
1. Canny Edge Detector
2. Hough Transform
Canney
Edge
Detector
Canny
Edge
Detector
Example
Hough Transform
Accumulator array for
Hough Transform
Hough
Transform for
Accumulating
Straight
Lines
Hough
Transform
Example
Hough
Transform
for
Extracting
Straight
Lines
Example of
Hough
Transform
Morphological Filter
Morphological
Filter
Example
Example
Closing & Opening
Opening Example
Morphological
Filter Example 1
Structure Element Example 1
Morphological
Filter
Example
2
Structure Element Example 2
Conditional Dilation
Conditional
Dilation
Example
Image Transform
I (k )  s1 f1 (k )  s2 f 2 (k )  
Basis Vectors
Transform
Coefficients
Fourier Transform
1. Remove high frequency noise
2. Extract texture features
3. Image compression
Discrete Fourier Transform
I (k )  a0  a1 cosk  b1 sin k  a2 cos2k  b2 sin 2k  
a1  jb1  I (k )  cosk  j  I (k )  sin k  I (k )  e   I (k )e
k
j 2 ( ur  vc)
N 1 N 1


N
I
(
r
,
c
)
e



 F (u, v)  r 0 c 0

N

j 2 ( ur  vc)
N 1 N 1

N
F
(
u
,
v
)
e



u 0 v 0
 I (r , c) 
N

k
Magnitude & Phase of
Discrete Fourier Transform
Magnitude F (u, v)  R(u, v) 2  I (u, v) 2
 I (u, v) 
Phase   (u, v)  tan 

 R(u, v) 
1
Separability of Fourier Transform
F (u, v) 
N 1
N 1
r 0
c 0
  I ( r , c )e

j 2 ( ur  vc)
N
N
j 2ur
N 1


F ( r , v )e N


 F (u, v)  r 0

N
j 2vc

N 1

 F ( r , v )   I ( r , c )e N

c 0
N 1  j 2ur N 1
N

e
r 0
 I ( r , c )e
c 0
N

j 2vc
N
Properties of Fourier Transform
f (r , c)  F (u, v)

j 2 ( ur0  vc0 )

 f (r  r , c  c )  F (u, v)e
N
0
0

 f (r , c)  F (u, v)

1
u v
 f (ar, bc) 
F( , )
ab a b

Translation
Brightness
Scaling
f (d , )  F ( ,  )
 f (d ,   0 )  F ( ,    0 )
Rotation
Discrete Cosine Transform
N 1 N 1

 u (2r  1) 
 v (2c  1) 
F
(
u
,
v
)


(
u
)

(
v
)
I
(
r
,
c
)
cos
cos



 2N

 2N






r 0 c 0

N 1 N 1
 u (2r  1) 
 v (2c  1) 
 I (r , c) 
 (u ) (v)C (u , v) cos
cos





 2N

 2N

u 0 v 0
 1
for u,v  0

where  (u ), (v)   N
 2 for u,v  0
 N
Discrete
Cosine
Transform
Basis
Images
Walsh-Hadamard Transform

bi ( r ) pi ( u )  bi ( c ) pi ( v ) 

I (r , c) 1i0



W (u, v)  r 0 c 0

N

n1
N 1 N 1
bi ( r ) pi ( u )  bi ( c ) pi ( v ) 


W (u, v) 1i0



u 0 v 0
 I (r , c) 
N

N 1
N 1
n1
WalshHadamard
Basis
Images
Construction of Walsh-Hadamard
Basis Images
Frequency Domain Image Filtering
Bandpass Filtering
Symmetry of
the Fourier
Transform
Symmetry
of the
Discrete
Cosine
Transform
Ideal Lowpass Filter
Nonideal Lowpass Filter
Highpass Filter
Bandpass & Bandreject Filter
Convolution Theorem
F ( g ( x, y)  h( x, y))  F ( g ( x, y))F (h( x, y))  G(u, v) H (u, v)
1.
Fourier transform the image g(x,y) to obtain its frequency representation G(u,v)
2.
Fourier transform the mask h(x,y) to obtain its frequency representation H(u,v)
3.
Multiply G(u,v) and H(u,v) pointwise
4.
Apply the inverse Fourier transform to obtain the filtered image
Download