|
|
|
Professor Hager |
|
http://www.cs.jhu.edu/~hager |
|
|
|
|
Image noise |
|
|
|
Filtering by Convolution |
|
|
|
Properties of Convolution |
|
|
|
|
|
|
|
|
An experiment: take several images of a static
scene and look at the pixel values |
|
|
|
|
|
Noise is commonly modeled using the notion of
“additive white noise.” |
|
Scalar example:
I(x) = I*(x) + n(x) |
|
Images: I(i,j,t) = I*(i,j,t) + n(i,j,t) |
|
Note that n(i,j,t) is independent of n(i’,j’,t’)
unless i’=i,j’=j,t’=t. |
|
Typically we assume that n (noise) is
independent of image location --- that is, it is i.i.d |
|
|
|
|
Properties of temporal image noise: |
|
|
|
|
|
|
An experiment: take several images of a static
scene and look at the pixel values |
|
|
|
|
|
|
|
Impulsive noise |
|
randomly pick a pixel and randomly set ot a
value |
|
saturated version is called salt and pepper
noise |
|
|
|
Quantization effects |
|
Often called noise although it is not
statistical |
|
|
|
Unanticipated image structures |
|
Also often called noise although it is a real
repeatable signal. |
|
|
|
|
|
It is common to assume that: |
|
spatial noise in an image is consistent with the
temporal image noise |
|
the noise is independent and identically
distributed |
|
|
|
|
|
Thus, we can think of the image itself as an
additive noise process |
|
|
|
|
|
Averaging is a common way to reduce noise |
|
instead of temporal averaging, how about spatial |
|
|
|
For a pixel in image I at I,j |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For a pixel in image I at I,j |
|
|
|
|
|
|
|
|
|
Computing this for every pixel location is the convolution
of the image I with the template (or kernel) consisting of a 3x3 array of 1’s. |
|
|
|
Note that is this O(n2m2)
for an nxn image and mxm template. |
|
|
|
Note we have to normalize the template to 1 to
make sure we don’t introduce any scaling into the image. |
|
|
|
|
|
|
|
|
|
|
|
|
We often
write I’ = B*I to represent the convolution of I by B. B is referred to as the kernel of the
convolution (or sometimes the “stencil” in the discrete case). |
|
|
|
Note convolution is |
|
Associative |
|
Commutative |
|
Linear |
|
|
|
We are using a discrete convolution; we will see
this is not always consistent with an underlying continuous convolution
that we may wish to implement |
|
|
|
Convolution is formally defined on unbounded
images and kernels. |
|
padding schemes: |
|
pad with zeros (same size vs. full size) |
|
compute only legal values |
|
|
|
|
|
|
|
|
Another way to think about convolution is in
terms of how it changes the frequency distribution in the image. |
|
|
|
Recall the fourier representation of a function |
|
|
|
F(u) = s f(x) e-2p i
u x dx |
|
recall that e-2p i u
x = cos(2p u x) – i sin (2 p u x) |
|
Also we have f(x) = s F(u) e-2p
i u x du |
|
F(u) = |F(u)| ei F(u) |
|
a decomposition into magnitude and phase |
|
|F(u)|^2 is the power spectrum |
|
|
|
Questions: what function takes many many many
terms in the Fourier expansion? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If H and G are images, and F(.) represents
Fourier transform, then |
|
|
|
|
|
Thus, one way of thinking about the properties
of a convolution is by thinking of how it modifies the frequencies of the
image to which it is applied. |
|
|
|
In particular, if we look at the power spectrum,
then we see that convolving image H by G attenuates frequencies where G has
low power, and amplifies those which have high power. |
|
|
|
|
|
This is referred to as the Convolution Theorem |
|
|
|
|
|
|
|
|
Professor Hager |
|
http://www.cs.jhu.edu/~hager |
|
|
|
|
Gaussian Filtering |
|
|
|
Edges and derivative filters |
|
|
|
|
|
|
|
|
Ideally, we would like an averaging filter that
removes (or at least attenuates) high frequencies beyond a given range |
|
|
|
|
|
|
|
|
|
It is not hard to show that the FT of a Gaussian
is again a Gaussian. Hence, it
operates as a low pass filter. |
|
|
|
Note that in general, we truncate --- a good
general rule is that the width (w) of the filter is at least such that w
> 5 s. Alternatively we can just
stipulate that the width of the filter determines s (or vice-versa). |
|
|
|
Note that in the discrete domain, we truncate
the Gaussian, thus we are still subject to ringing like the box filter. |
|
|
|
|
|
Recall that convolution is commutative. Suppose I use the templates gx = exp(-i2/2
s2) and By = gy = exp(-j2/2 s2) Then |
|
|
|
gx * (gy * I) = (gx * gy) * I |
|
|
|
but, it is not hard to show that the first
convolution is simply the 2-D Gaussian that we defined previously! |
|
|
|
In general, this means that we can “separate”
the 2-D Gaussian convolution into 2 1-D convolutions with great
computational cost savings. |
|
|
|
A good exercise is to show that the box filter
is also separable. |
|
|
|
|
|
Note that for a 256 gray level image, we can precompute
all values of the convolution and avoiding multiplication. |
|
|
|
For the box filter, we can implement any size
using 4n additions per pixel. |
|
|
|
Also note that, by the central limit theorem,
repeated box filter averaging yields approximations to a Gaussian filter. |
|
|
|
Finally, note that a sequence of filtering
operations can be collapsed into one by associativity. |
|
in general, this is not a win, but we’ll see
examples where it is ... |
|
|
|
|
|
|
|
Suppose we consider the convolution template as
a “vector”: |
|
T = [T1,T2,T3 .... Tn] |
|
|
|
Likewise, consider a region of the image to
which the convolution is applied as a vector |
|
I = [I1,I2,...In] |
|
|
|
Then the value of the convolution at a point is
just the “dot product” |
|
v = T ¢ I |
|
|
|
Thus, we can also think of convolution as a kind
of “pattern match” where regions of the image that are “similar” to T
respond more strongly than those that are dissimlar (up to a scale factor) |
|
|
|
|
|
Thus far, we’ve only considered convolution
kernels that are smoothing filters. |
|
|
|
Consider the following kernel: |
|
|
|
[ -1, 1] |
|
|
|
|
|
Thus far, we’ve only considered convolution
kernels that are smoothing filters. |
|
|
|
Consider the following kernel: |
|
|
|
[ -1;1] |
|
|
|
|
|
Recall from calculus for a function of two
variables f (x,y) : |
|
|
|
The gradient: points in the direction of maximum
increase. |
|
|
|
Its magnitude is proportional to the rate of
increase. |
|
|
|
The total derivative in the direction n = n ¢ r
f |
|
|
|
The kernel [-1,1] is a way of computing the x
derivative |
|
|
|
The kernel [-1;1] is a way of computing the y
derivative |
|
|
|
|
|
|
|
|
|
One problem with differences is that they by
definition reduce the signal to noise ratio (can you show this?) |
|
|
|
Recall smoothing operators (the Gaussian!)
reduce noise. |
|
|
|
Hence, an obvious way of getting clean images
with derivatives is to combine derivative filtering and smoothing: e.g. |
|
|
|
G * Dx * I = Dx * G * I |
|