lecture_2

advertisement
Image Transforms
Transforming images to images
Classification of Image
Transforms

Point transforms



Local transforms


modify individual pixels
modify pixels’ locations
output derived from neighbourhood
Global transforms

whole image contributes to each output
value
Image Processing and Computer Vision: 2
2
Point Transforms

Manipulating individual pixel values



Histogram manipulation


Brightness adjustment
Contrast adjustment
equalisation
Image magnification
Image Processing and Computer Vision: 2
3
Grey Scale Manipulation



Brightness modifications
Contrast modifications
Histogram manipulation
Image Processing and Computer Vision: 2
4
Brightness Adjustment
Add a constant to all values
g’ = g + k
(k = 50)
Image Processing and Computer Vision: 2
5
Contrast Adjustment
Scale all values by a constant
g’ = g*k
(k = 1.5)
Image Processing and Computer Vision: 2
6
Image Histogram

Measure frequency of occurrence of
each grey/colour value
Grey Value Histogram
12000
Frequency
10000
8000
6000
4000
2000
256
241
226
211
196
181
166
151
136
121
106
91
76
61
46
31
1
16
0
Grey Value
Image Processing and Computer Vision: 2
7
Histogram Manipulation

Modify distribution of grey values to
achieve some effect
Image Processing and Computer Vision: 2
8
Equalisation/Adaptive
Equalisation

Specifically to make histogram uniform
Grey Value Histogram
12000
Frequency
10000
8000
6000
4000
2000
256
241
226
211
196
181
166
151
136
121
91
106
76
61
46
31
16
1
0
Grey Value
Image Processing and Computer Vision: 2
9
Equalisation Transform


Equalised image has n x m/l pixels per grey
level
Cumulative to level j


jnm/l pixels
Equate to a value in input cumulative
histogram C[i]



C[i] = jnm/l
j = C[i]l/nm
Modifications to prevent mapping to –1.
Image Processing and Computer Vision: 2
10
Thresholding


Transform grey/colour image to binary
if f(x, y) > T output = 1
else 0
How to find T?
Image Processing and Computer Vision: 2
11
Threshold Value

Manual




User defines a threshold
P-Tile
Mode
Other automatic methods
Image Processing and Computer Vision: 2
12
P-Tile


If we know the proportion of the image
that is object
Threshold the image to select this
proportion of pixels
Image Processing and Computer Vision: 2
13
Mode
Threshold at the minimum between the
histogram’s peaks.
Image Processing and Computer Vision: 2
14
Automated Methods
Find a threshold  such that
Average l
Average h



l
h
2
(Start at  = 0 and work upwards.)
Image Processing and Computer Vision: 2
15
Image Magnification

Reducing



new value is weighted sum of nearest
neighbours
new value equals nearest neighbour
Enlarging


new value is weighted sum of nearest
neighbours
add noise to obscure pixelation
Image Processing and Computer Vision: 2
16
Local Transforms


Convolution
Applications



smoothing
sharpening
matching
Image Processing and Computer Vision: 2
17
Convolution Definition


g' r, c   
 gr  x, c  y   t x, y 
x   y  
Place template on image
Multiply overlapping values in image and
template
Sum products and normalise
(Templates usually small)
Image Processing and Computer Vision: 2
18
Example
Image
… .
…3
…4
…4
…4
…4
… .
.
5
5
6
6
5
.
.
7
8
9
9
8
.
Template
.
4
5
6
5
5
.
. ...
4…
4…
4…
3…
4…
. ...
1
1
1
1
2
1
Result
1
1
1
…
…
…
…
…
…
…
.
.
.
.
.
.
.
.
.
6
6
6
.
.
.
.
6
7
7
.
.
.
.
6
6
6
.
.
. ...
. ...
.…
.…
.…
. ...
. ...
Divide by template sum
Image Processing and Computer Vision: 2
19
Separable Templates

Convolve with n x n template


n2 multiplications and additions
Convolve with two n x 1 templates

2n multiplications and additions
Image Processing and Computer Vision: 2
20
Example

Laplacian template

Separated kernels
-1 2 -1
Image Processing and Computer Vision: 2
0 –1 0
-1 4 –1
0 –1 0
-1
2
-1
21
Composite Filters

Convolution is distributive
A  B  C    A  B   C



Can create a composite filter and do a
single convolution
Not convolve image with one filter and
convolve result with second.
Efficiency gain
Image Processing and Computer Vision: 2
22
Applications

Usefulness of convolution is the effects
generated by changing templates

Smoothing


Sharpening


Noise reduction
Edge enhancement
Template matching

A later lecture
Image Processing and Computer Vision: 2
23
Smoothing



Aim is to reduce noise
What is “noise”?
How is it reduced



Addition
Adaptively
Weighted
Image Processing and Computer Vision: 2
24
Noise Definition

Noise is deviation of a value from its
expected value

Random changes


xx+n
Salt and pepper

x  {max, min}
Image Processing and Computer Vision: 2
25
Noise Reduction

By smoothing
S(x + n) = S(x) + S(n) = S(x)



Since noise is random and zero mean
Smooth locally or temporally
Local smoothing


Removes detail
Introduces ringing
Image Processing and Computer Vision: 2
26
Adaptive Smoothing

Compute smoothed value, s
Output = s if |s – x| > T
x otherwise
Image Processing and Computer Vision: 2
27
Median Smoothing
Median is one value in an ordered set:
n 1
2
n odd
 n n 1
average ,
 n even
2 2 
1 2 3 4 5 6 7  median = 4
2 3 4 5 6 7  median = 4.5
Image Processing and Computer Vision: 2
28
Original
Smoothed
Median Smoothing
Image Processing and Computer Vision: 2
29
Gaussian Smoothing



To reduce ringing
Weighted smoothing
Numbers from Gaussian (normal)
distribution are weights.
Image Processing and Computer Vision: 2
30
Sharpening

What is it?



Enhancing discontinuities
Edge detection
Why do it?


Perceptually important
Computationally important
Image Processing and Computer Vision: 2
31
Edge Definition
An edge is a significant local change in image
intensity.
Image Processing and Computer Vision: 2
32
Edge Types

Step edge
Line edge
Roof edge

Real edges


Image Processing and Computer Vision: 2
33
First Derivative, Gradient Edge
Detection


If an edge is a discontinuity
Can detect it by differencing
Image Processing and Computer Vision: 2
34
Roberts Cross Edge Detector


-1 0
0 -1
0
1
1
0
Simplest edge detector
Inaccurate localisation
Image Processing and Computer Vision: 2
35
Prewitt/Sobel Edge Detector
-1 -1 -1
0 0 0
1 1 1
Image Processing and Computer Vision: 2
-1 0
-1 0
-1 0
1
1
1
36
Edge Detection

Combine horizontal and vertical edge
estimates
Mag  h  v
2
2
Image Processing and Computer Vision: 2
and
v
  tan
h
1
37
Problems


Enhanced edges are noise sensitive
Scale

What is “local”?
Image Processing and Computer Vision: 2
38
Canny/Deriche Edge Detector

Require




edges to be detected
accurate localisation
single response to an edge
Solution

Convolve image with Difference of
Gaussian (DoG)
Image Processing and Computer Vision: 2
39
Example Results
Image Processing and Computer Vision: 2
40
Second Derivative Operators
Zero Crossing




Model HVS
Locate edge to subpixel accuracy
Convolve image with Laplacian of
Gaussian (LoG)
Edge location at crossing of zero axis
Image Processing and Computer Vision: 2
41
Example Results
Image Processing and Computer Vision: 2
42
Image Processing and Computer Vision: 2
43
Global Transforms



Computing a new value for a pixel using
the whole image as input
Cosine and Sine transforms
Fourier transform




Frequency domain processing
Hough transform
Karhunen-Loeve transform
Wavelet transform
Image Processing and Computer Vision: 2
44
Cosine/Sine


A halfway solution to the Fourier
Transform
Used in image coding
x  N 1 y  N 1
DCT i, j   2 N C i C  j 

x 0
y 0
 2 x  1i   2 y  1 j 
pixel x, y  cos
 cos

2N
 2N  

 1
if x  0

C x    2
 1 otherwise
Image Processing and Computer Vision: 2
45
Fourier

All periodic signals can be represented by a sum of
appropriately weighted sine/cosine waves

 

0  

 




 

 
N 1 

and
F
F
W
W
W
1

n,i
N

0, 0

N 1,0
 j 2
e




0, N 1  




N 1, N 1
 
W
W


0 
 


N 1
f
f
ni
N
Image Processing and Computer Vision: 2
46
Transformed section of BT Building image.
Image Processing and Computer Vision: 2
47
Frequency Domain Filtering

Convolution Theorem:
Convolution in spatial domain
is equivalent to
Multiplication in frequency domain
Image Processing and Computer Vision: 2
48
Smoothing
Suppress high frequency components
Image Processing and Computer Vision: 2
49
Sharpening
Suppress low frequency components
Image Processing and Computer Vision: 2
50
Example
Image Processing and Computer Vision: 2
51
Wavelet

A hierarchical representation
detail
Image Processing and Computer Vision: 2
52
Hough Transform


To detect curves analytically
Example

straight lines
Image Processing and Computer Vision: 2
53
Straight Line
y = mx + c
gradient m, intercept c
c = -mx + y
gradient -x, intercept y
ALL points in (x, y) transform to a straight
line in (c, m)
Can therefore detect collinear points
Image Processing and Computer Vision: 2
54
Analytic Curve Finding

Alternative representation


to avoid infinities
Other curves

higher dimensional accumulators
Image Processing and Computer Vision: 2
55
Performance Improvement
Techniques


Look at pairs of points
Use edge orientation
Image Processing and Computer Vision: 2
56
Karhunen-Loeve
(Principal Component)


A compact method of representing
variation in a set of images
PCs define a co-ordinate system



1st PC records most of variation
2nd PC records most of remainder
etc
Image Processing and Computer Vision: 2
57
Method






Take a set of typical images
Compute mean image and subtract from each
sample
Transform images into columns
Group images into a matrix
Compute covariance matrix
Compute eigenvectors


these are the PCs
eigenvalues show their importance
Image Processing and Computer Vision: 2
58
Uses


Compact representation of variable data
Object recognition
Image Processing and Computer Vision: 2
59
Uses



Hierarchical representation
Multiresolution processing
Coding
Image Processing and Computer Vision: 2
60
Geometric Transformations

Definitions


Affine and non-affine transforms
Applications

Manipulating image shapes
Image Processing and Computer Vision: 2
61
Affine Transforms
Scale, Shear, Rotate, Translate
Length and areas preserved.
x’ = a b c
x
y’
d e f
y
1
g h i
1
Change values of transform matrix elements according
to desired effect.
[ ] [ ][ ]
a, e  scaling
b, d  shearing
a, b, d, e  rotation
c, f  translation
Image Processing and Computer Vision: 2
62
Affine Transform Examples
Image Processing and Computer Vision: 2
63
Warping Example
Ansell Adams’ Aspens
x' , y '  1.2 x2 y  1.2 x y 2  x
Image Processing and Computer Vision: 2
64
Image Resampling



Moving source to destination pixels
x’ and y’ could be non-integer
Round result


can create holes in image
Manipulate in reverse


where did warped pixel come from
source is non-integer

interpolate nearest neighbours
Image Processing and Computer Vision: 2
65
You Should Know…

Point transforms


Local transforms


edge detection, smoothing
Global transforms


scaling, histogram manipulation,thresholding
Fourier, Hough, Principal Component, Wavelet
Geometrical transforms
Image Processing and Computer Vision: 2
66
Download