1. ESTIMATING NOISE PARAMETER
&
FILTERING
Dr.S.SHAJUN NISHA,
MCA.,M.Phil.,M.Tech.,MBA.,Ph.D
Assistant Professor &Head
PG & Research Dept. of Computer Science
Sadakathullah Appa College
Shajunnisha_s@yahoo.com
+91 99420 96220
2. 2
Estimating Noise Parameter
The parameters of periodic noise typically are estimated by
analyzing the Fourier spectrum of the image.
Periodic noise tends to produce frequency spikes that often
can be detected even by visual inspection.
In the case of noise in the spatial domain, the parameters of
the PDF may be known partially from sensor
specifications. However, it is often necessary to estimate
them from sample images.
3. Estimating Noise Parameter Cont…
In general, the relationships between the mean, m, and
variance, , of the noise, and the parameters a and b
required to completely specify the noise PDFs of interest
(see Table 5.1).
Problem: Estimating mean and variance from the sample
image(s) and then using them to solve for a and b.
4. 4
Estimating Noise Parameter – cont...
Let zi be a discrete random variable that denotes intensity
levels in an image. Note that a random number generator
usually produces numbers in the range [0 1].
You need to multiply that with the Max intensity value to
get the intensity. Assume p(zi), I = 0, 1, 2, …, L-1, be the
corresponding normalized histogram, where L is the
number of possible intensity values.
5. The central moments (moments around the mean) is
defined as:
Where n is the moment order, and m is the mean:
Note that histogram is normalized,
so sum of all p’s is 1.
From the first equation on the previous page, we can
determine that = 1, and = 0.
and:
1
0
)(
L
i
ii zpzm
1
0
2
2 )()(
L
i
ii zpmz
6. 6
Estimating Noise Parameter – cont…
Is the variance. We only go this far up (second
component).
Function statmoments computes the mean and central
moments up to order n, and returns them in row vector v.
statmoments ignores these two moments and instead lets
v(1) = m and v(k) = for k = 2,3, …, n.
0 1
7. 7
Example:
Consider this 4x4 image and
computed the first three central
moments.
m = 9
p0 = 2/16 , p4 = 4/16 , p8 = 1/16,
p10 = 6/16, p20 = 3/16
4102010
8440
1010410
2010020
1
0
)()(
L
i
i
n
in zpmz
10 01 2
8. 8
Estimating Noise Parameter – cont.
In MATLAB: [u , unv] = statmoments(p, n)
Where p is the histogram vector and n is the number of
moments to compute. p must be 2q for unitq images.
Output vector u contains the normalized moments based on
values of the random variable that have been scaled to the
range [0, 1]. All the moments are also in the same range.
Vector unv contains the same moments as v, but computed
with the data in its original range of values.
Example:
If length(p) = 256 and v(1) = 0.5, then unv(1) would have
the value 127.5, which is half of the range [0 255].
9. 9
Estimating Noise Parameter – cont.
Sometimes the noise parameter must be estimated
directly from a given noisy image or set of images. In such
cases we select part of the image that is as featureless as
possible to emphasize the primary noise as much as
possible.
To select region of interest (ROI) in MATLAB, we can use
roipoly function, which generates a polygonal ROI:
B = roipoly(f, c, r)
Where f is the image of interest, and c and r are vectors of
corresponding column and row coordinate of the vertices
of the polygon.
B is a binary image the same size as f with 0’s outside the
region of interest and 1’s inside. It is used as a mask to
limit operations to within the region of interest.
10. 10
Estimating Noise Parameter – cont.
We can also set the ROI interactively:
B = roipoly(f)
Which displays the image f on the screen and allows the
user specify the polygon using the mouse.
Please see the help on this function to learn about other
ways we can run it.
13. 13
Histogram of the ROI
X = imnoise2(‘gaussian’, npix, 1, 147, 20)
So the noise seem to look like a Gaussian. So the best estimate for this noise is Gaussian.
Histogram of the image
14. 14
Periodic Noise Reduction by Frequency Domain Filtering
The periodic noise manifests itself as impulse-like bursts
that are often visible in the Fourier spectrum. The principal
approach for removing these components is via notch
filtering. The transfer function of a Butterworth notch filter
of order n is given by:
Where: D1(u,v) = [(u - M/2 – u0)2 + (v - N/2 – v0)2]1/2
And D2(u,v) = [(u - M/2 + u0)2 + (v - N/2 + v0)2]1/2
Where (u0, v0) and by symmetry (-u0, -v0) are locations of the
notches and D0 is the measure of their radius. Note: filter is
specified with respect to the center of the frequency
rectangle.
n
vuDvuD
D
vuH
),(),(
1
1
),(
21
2
0
15. 15
Direct Inverse Filtering
The simplest form to restore a degraded image is to find an
estimate as:
and then find an estimate of the image by taking the
inverse Fourier transform. This is called inverse filtering.
),(
),(
),(
vuH
vuG
vuF
),(
),(
),(),(
vuH
vuN
vuFvuF
What are the problems you will run into here?
Typical approach is to form the ratio shown at the top and then limit the frequencies
“near” the origin when you compute the inverse.
Why frequencies “near” the origin?
16. 16
Wiener Filtering
Wiener filtering is one of the best image restoration
approach. This approach seeks an estimate of f that
minimizes the statistical error function:
Where E is the expected value operator and f is the
undegraded image. The solution to this expression in
frequency domain is:
})ˆ{( 22
ffEe
imageundegradedtheofspectrumpowerthe|),(|),(
noisetheofspectrumpowerthe|),(|),(
),(ofconjugatecomplexthe),(
),(),(|),(|
functionndegradatiothe),(
),(
),(/),(|),(|
|),(|
),(
1
),(ˆ
2
2
*
*2
2
2
vuFvuS
vuNvuS
vuHvuH
vuHvuHvuH
vuH
where
vuG
vuSvuSvuH
vuH
vuH
vuF
f
f
),(/),( vuSvuS f
Is called noise-to-signal ratio
17. 17
),(/),( vuSvuS f
Wiener Filtering
The noise-to-signal ratio becomes zero when the noise
power spectrum becomes zero. See this:
Two other quantities can play a role in this model. One is
the average noise power:
And the average image power:
Where M and N denote the vertical and horizontal sizes of
the image and noise arrays, respectively. We can define a
ratio R as: that we will use in place of noise-to-
signal ratio on previous page.
u v
A vuS
MN
),(
1
u v
fA vuS
MN
f ),(
1
A
A
f
R
18. 18
),(
/|),(|
|),(|
),(
1
),(ˆ
2
2
vuG
fvuH
vuH
vuH
vuF
AA
Wiener Filtering
We get a new model:
Which is called parametric Wiener filter.
This filter is implemented in MATLAB as:
fr = deconvwnr(g, PSF)
This assumes that the noise-to-signal ratio is zero. This one:
fr = deconvwnr(g, PSF, NSPR)
Assumes that the noise-to-signal power ratio is known, either as a constant or as an array. The
parametric version:
fr = deconvwnr(g, PSF, NACORR, FACORR)
Assumes the autocorrelation functions, NACORR and FACORR of the noise and undegrated
image are known.
20. 20
Wiener Filtering Example – cont.
Weiner filtering of degraded image g,
fr1 = deconvwnr(g, PSF);
This assumed
noise-to-signal
ratio was 0.
21. 21
Sn = abs(fft2(noise)).^2; % noise power spectrum
nA = sum(Sn(:) )/prod(size(noise)); % noise average power
Sf = abs(fft2(f)).^2; % image power spectrum
fA = sum(Sf(:))/prod(size(f)); % image average power
R = nA/fA; /% ratio
To restore the image we use R for noise-to-signal ratio in
the Wiener filtering:
fr2 = deconvwnr(g, PSF, R);
This produces the image on the next page.
),(
/|),(|
|),(|
),(
1
),(ˆ
2
2
vuG
fvuH
vuH
vuH
vuF
AA
Compute:
Wiener Filtering Example
23. 23
Now we will use autocorrelation functions in the restoration.
NCORR = fftshift(real(ifft2(Sn)));
ICORR = fftshift(real(ifft2(Sf)));
fr3 = deconvwnr(g, PSF, NCORR, ICORR);
The result is very close to the
original image, but some
noise is still evident.
Note, here we knew the
noise function and we were
able to estimate correct
parameters.
24. 24
Constrained Least Squares (Regularized) Filtering
The definition of 2-D discrete convolution is:
The degradation model in matrix form is:
We want to find the minimum of a criterion function:
The frequency domain solution
to this problem is given as:
Where is a parameter that must be adjusted so that the constraint is satisfied and P(u,v)
is the Fourier transform of the function:
1
0
1
0
),(),(
1
),(),(
M
m
N
n
nymxhnmf
MN
yxfyxh
),(
|),(||),(|
),(
),(ˆ
22
*
vuG
vuPvuH
vuH
vuF
010
141
010
),( yxP
Hfg
1
0
1
0
22
constraintthesubject to)],([
M
x
N
y
yxfC
22
||η||||fHg|| ˆ
This method is based on the
Laplacian Transform
25. 25
Constrained Least Squares (Regularized) Filtering
In MATLAB, the Constrained least squares filtering is done by function deconvreg as:
fr = deconvreg(g, PSF, NOISEPOWER, RANGE)
Where g is the corrupted image, fr is the restored image, NOISEPOWER is proportional to
, and RANGE is the range values where the algorithm is limited to look for a solution for .
The default range is [10-9 , 109]. A good starting estimate for NOISEPOWER is ,
where M and N are dimensions of the image and the parameters inside the brackets are
the noise variance and noise squared mean.
2
||||
][ 22
mMN
27. 27
fr = deconvreg(g, PSF, 4);
The initial estimate of NOISEPOWER is (64)2[0.001 – 0] ~ 4.
28. 28
fr = deconvreg(g, PSF, 0.4, [1e-7 1e7]);
The result is not as good as that we
obtained with the Wiener’s method. It is
obvious why. When we used that
method we knew the noise and image
spectra.
29. 29
Iterative Nonlinear Restoration Using the Lucy-
Richardson Algorithm
The previous three methods are all linear. They also are
“direct” in the sense that once the restoration filter is
specified, the solution is obtained via one application of
the filter.
The non-linear iterative techniques have been gaining
acceptance. They usually yield better result than the linear
methods. Perhaps the only drawback to using this
methods is that their behavior is not always predictable
and that they require significant computational resources.
One of the non-linear techniques discussed in the text is
Lucy-Richardson (L-R) algorithm.
30. 30
The L-R Algorithm
This algorithm is based on a maximum-likelihood
formulation in which the image is modeled with Poisson
statistics. Maximizing the likelihood function of the model
yields an equation that is satisfied when the following
iteration converges.
As before “*” denotes convolution, is the undegraded
image, g is the degraded image, and h is the spatial
representation of the degraded function. Note that the
subscript refers to the iteration number.
As in any iterative approach, the question is when to stop
the iteration. We usually stop the iteration when the
result is somewhat acceptable.
),(ˆ),(
),(
),(),(ˆ),(ˆ
1
yxfyxh
yxg
yxhyxfyxf
k
kk
fˆ
31. 31
The L-R Algorithm
In MATLAB the L-R algorithm is implemented by function
deconvlucy:
fr = deconvlucy(g, PSF, NUMIT, DAMPAR, WEIGHT)
Where fr is the restored image, g is the degraded image,
PSF is the point spread function, NUMIT is the number of
iterations (default is 10). DAMPAR denotes the threshold
deviation of the resulting image from image g and
WEIGHT is an array of same size as g that assigns weight to
each pixel to reflect its quality.
fˆ
33. 33
Create a 7x7 PSF with standard deviation of 10
PSF = fspecial(‘guassian’, 7, 10);
Then blur the image using PDF and add to it Gaussian noise of zero mean and standard
deviation of 0.01: SD = 0.01;
g = imnoise(imfilter(f, PSF), ‘gaussian’, 0, SD^2);
34. 34
DAMPAR = 10*SD;
LIM = ceil(size(PSF, 1)/2);
WEIGHT = zeros(size(g));
WEIGHT(LIM + 1:end – LIM, LIM + 1:end – LIM) = 1;
WEIGHT is a 64x64 array with a border of 0’s 4 pixels
wide and the rest all 1’s.
NUMIT = 5; % Number of iterations
fr = deconvlucy(g, PSF, NUMIT, DAMPAR, WEIGHT);
35. 35
NUMIT = 10; % Number of iterations
fr = deconvlucy(g, PSF, NUMIT, DAMPAR, WEIGHT);
10 iterations 20 iterations
36. 36
With 100 iterations we didn’t get much better results. It
however costs much more computing time.
The thin black border is the result of 0’s in array
WEIGHT.