Lec03 Image Proc
Lec03 Image Proc
CS 4487/9587
Elements of
Image (Pre)-Processing
and Feature Detection
Acknowledgements: slides from Steven Seitz, Aleosha
Efros, David Forsyth, and Gonzalez & Woods
The University of
window-center correction
histogram equalization
Filtering (linear and non-linear) Extra Reading: Szeliski, Sec 3.2-3.3
Examples:
The University of
Examples:
Examples:
Examples:
g ( x, y)
more on filtering later
h(u, v) f ( x u, y v) du dv
|u|
|v|
The University of
g ( x, y) t ( f ( x, y))
for each original image intensity value I function t()
returns a transformed intensity value t(I).
NOTE: we will often use
I t (I ) notation Ip instead of f(x,y) to
denote intensity at pixel p=(x,y)
Point Processing:
I t (I )
I
The University of
Point Processing:
Negative Ontario
Ip or f ( x, y) I p or g ( x, y)
t ( I ) 255 I
g ( x, y) t ( f ( x, y)) 255 f ( x, y)
The University of
Point Processing:
Point Processing:
Point Processing:
Point Processing:
Point Processing:
Point Processing:
1)
2)
The University of
Point Processing:
3)
4)
The University of
i i
t (i) p( j )
nj
= cumulative distribution
n
j 0 j 0 of image intensities
Point processing
Histogram Equalization Ontario
i i
t (i) p( j )
nj
= cumulative distribution
n
j 0 j 0 of image intensities
I=t(I) is a random variable with uniform distribution over its range [0,1]
That is, transform image I will have a uniformly-spread histogram (good contrast)
The University of
Point Processing:
256
Output gray level
0 60000
input gray level
(high dynamic range image)
The University of
Point Processing:
256
Output gray level
0 60000
input gray level
(high dynamic range image)
The University of
Point Processing:
256
window
output gray level
0 center 60000
Point Processing:
Window = 4000
Center = 500
The University of
Point Processing:
Window = 2000
Center = 500
The University of
Point Processing:
Window = 800
Center = 500
The University of
Point Processing:
Window = 0
Center = 500
Point Processing:
matrix M
The University of
matrix M
The University of
matrix M
h [i] [a b c]
and can be written (for kernel of size 2k+1) as:
k
This pattern is very common
- same entries in each row
g [i] h [u] f [i u]
u k
- all non-zero entries near the diagonal
The above allows negative filter indices. When
gM f you implement need to use: h[u+k] instead of h[u]
The University of
g h f
convolution has additional technical properties: commutativity, associativity. Also, nice properties wrt Fourier analysis.
(see Szeliski Sec 3.2, Gonzalez and Woods Sec. 4.6.4)
The University of
2D filtering
Noise Ontario
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 0 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
The University of
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 20 10
0 0 0 90 90 90 90 90 0 0 0 20 40 60 60 60 40 20
0 0 0 90 90 90 90 90 0 0 0 30 60 90 90 90 60 30
0 0 0 90 90 90 90 90 0 0 0 30 50 80 80 90 60 30
0 0 0 90 0 90 90 90 0 0 0 30 50 80 80 90 60 30
0 0 0 90 90 90 90 90 0 0 0 20 30 50 50 60 40 20
0 0 0 0 0 0 0 0 0 0 10 20 30 30 30 30 20 10
0 0 90 0 0 0 0 0 0 0 10 10 10 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
The University of
Effect of
mean filters Ontario
The University of
Gaussian
noise Ontario
The University of
f ( x , y ) f ( x, y ) f ( xi 1 , y) f ( xi 1 , y)
f lim
x f
x
0
2 x
x f (convolution)
Now this is linear and shift
invariant, so must be the
0 0 0
result of a convolution. 1
with kernel 1 0 -1
2x
0 0 0
x [u, v]
sometimes this may not be a very good way
to do things, as we shall see
The University of
f ( x , y ) f ( x, y ) f ( xi 1 , y) f ( xi 1 , y)
f lim
x f
x
0
2 x
x f (convolution)
Now this is linear and shift
invariant, so must be the
0 0 0
result of a convolution. 1
with kernel 1 0 -1
2x
0 0 0
x [u, v]
sometimes this may not be a very good way
to do things, as we shall see
The University of
x f
The University of
x f x f x f
Issue: noise
smooth before differentiation
two convolutions: smooth, and then differentiate?
actually, no - we can use a derivative of Gaussian filter
because differentiation is convolution, and
convolution is associative x ( H f ) ( x H ) f
x H y H
The University of
( x H ) f
Ontario
The scale of the smoothing filter affects derivative estimates, and also
the semantics of the edges recovered.
The University of
x f y f
1 0 -1 1 2 1
1 1
2 0 -2 0 0 0
8x 8y
1 0 -1 -1 -2 -1
x [u, v] y [u, v]
The University of
f f
The absolute value | f | ( x ) 2 ( y ) 2 ( x f ) 2 ( y f ) 2 small image
gradients in low
is large at image boundaries textured areas
The direction of the gradient corresponds to the direction of the steepest ascend
- normally gradient is orthogonal to object boundaries in the image.
Comment: vector f is independent of
The University of
f f 2 2
f 2 2 [ x y ] f f
x
x y y divergence
of gradient
rotationally invariant
second derivative for 2D functions
0 0 0 0 1 0 0 1 0
1 -2 1 0 -2 0 1 -4 1
0 0 0 0 1 0 0 1 0
G image should
be smoothed a bit first
LoG
x2 y2
1 x y 2 2
LoG( x, y ) 4
1 e
2 2
2
2
http://homepages.inf.ed.ac.uk/rbf/HIPR2/log.htm
The University of
f f2 2
For simplicity, assume f(x,y) = const(y).
f 2 2 Then, Laplacian of f is simply
x y a second derivative of f(x) = f(x,y)
LoG
G image should
be smoothed a bit first
http://homepages.inf.ed.ac.uk/rbf/HIPR2/log.htm
The University of
- =
unsharp mask
+a = ?
unsharp mask
The University of
(1 a ) I a G * I [(1 a )G 1 a G 2 ] * I
1 2
U I G*I I a mask
unsharp U
+a = ?
unsharp mask
The University of
Applying a filter at
some point can be seen
as taking a dot-product Insight
between the image and filters may look like the effects they
some vector are intended to find
filters find effects they look like
Filtering the image is a
set of dot products
x H y H
The University of
h [u, v] f [ x u, y v]
u k v k
| h | | ft |
template (filter, kernel, mask)
h of size n = (2k+1) x (2k+1)
division makes this
a non-linear operation
t=(x,y)
ft
image
h ft
ft patch
g[t ] cos(a )
at t
a h | h | | ft |
f n
image
raster-scan h and ft as vectors in Rn
vector lengths | z | z
i 1
2
i
The University of
t=(x,y) ft ft
image a hh (h h ) ( f t f t )
NCC
ft patch
g[t ]
| h h | | ft ft |
at t
image a hh (h h ) ( f t f t )
NCC
ft patch
g[t ]
n h ft
at t
between h and ft
f
image n
(a a ) (b b )
cov(a, b) E (a a )(b b ) 1
n (a a )(b b )
i 1
i i
n
pictures from Silvio Savarese The University of
hA hB hC hD
A
image f
C
C
templates
points mark local maxima of NCC
for each template
D
points of interest or feature points
The University of
u weighted sum of
patch w change measure for shift ds : squared differences
v
w( x, y) [ I ( x u, y v) I ( x, y)]
2
Ew (u, v) :
x, y
or
NOTE:
window support
functions w(x,y) = Gaussian
1 in window, 0 outside (weighted) support
The University of
I ( x u, y v) I ( x, y) I x u I y v dsT I
rate of change for I at (x,y) in direction (u,v) = ds (remember gradient definition on earlier slides!!!!)
this is 2D analogue of 1st order Taylor expansion
[ I ( x u, y v) I ( x, y) ]2 dsT I I T ds
w( x, y) [ I ( x u, y v) I ( x, y)]
2
Ew (u, v)
x, y
ds w( x, y ) I I ds ds M w ds
T T
T
x, y M w
The University of
u
Ew (u, v) [ u v ] M w dsT M w ds
v
at any window w
... w( x, y ) I I ...
(t.e. any image patch)
T
x, y M w
The University of
u paraboloid
Ew (u, v) [ u v ] M w dsT M w ds
v
M is a positive semi-definite matrix (Exercise: show that ds M ds 0 for any ds)
T
u
Points on this ellipsoid are shifts ds=(u,v)
2 2 giving the same value of energy E(u,v)=1.
2 1 Thus, the ellipsoid allows to visually compare
sensitivity of energy E to shifts ds in different directions
two eigen values of matrix Mw
The University of
1
The University of
det M
R
Trace M
det M 12
trace M 1 2
R should be large
(it implies that both are far from zero)
The University of
The Algorithm:
Rotation invariance
Ellipse rotates but its shape (i.e. eigenvalues) remains the same
Intensity scale: I a I
R R
threshold
?
Point descriptor should be:
1. Invariant 2. Distinctive
The University of
Interest points
Multi-scale Harris corners
Orientation from blurred gradient
Geometrically invariant to rotation
Descriptor vector
Bias/gain normalized sampling of local patch (8x8)
Photometrically invariant to affine changes in intensity
8 pixels