Image MSC2ok
Image MSC2ok
3-2020-? Lecture 2
Image Restoration
Image Restoration
• Image restoration methods are used to improve the appearance of an
image by applying a restoration process that uses a mathematical model
for image degradation.
• The degradation may be due to:
– Blurring caused by motion(Camera shake) or atmospheric
disturbance.
– Geometric distortion caused by imperfect lenses.
– Superimposed interference patterns caused by mechanical systems.
– Noise from electronic sources(Shot noise and quantization).
here
Image with uniform noise added Image with salt-and-pepper noise added
Gaussian Noise
Gaussian Noise
•Noise (image) can be classified according the distribution of the values of
pixels (of the noise image) or its (normalized) histogram, It is
characterized by two parameters, (mean) and σ2(variance), by
( g )2
• Gaussian distribution: P(g)
HISTOGRAMGaussian P ( g )
1
e 2 2
2 2
– g = gray level
– µ = mean (average)
– σ = standard deviation (σ2 = variance)
It is occurring from electronic noise in image
acquisition system.
12
Rayleigh distribution
Rayleigh distribution
( g a )2 P(g)
2 ( g a ) 2
HISTOGRAM
Rayleigh
P(g ) e 0 . 607
mean a
4
( 4 )
var iance 4
P(g)
Pa for g a
– p ( g ) Pb for g b
ep p e r
0 otherwise
n d- p
Salt-a
2
var iance
Laser based images
Gamma Distribution(Erlang):
Gamma Distribution(Erlang): g
g
g 1 a
HISTOGRAM P(g ) e
Gamma ( 1 )! a
var iance a 2
Noise
Noise
• There are various approaches to determine the type of noise that has
corrupted as image.
• Ideally, find an image that contains only noise, and then use its
histogram for the noise model.
– generates a noisy image, try to take picture of a blank wall.
• then compare this noise model to the ones available and select the best
match.
• In order to develop a valid model with any of the above approaches,
many sample images need to be evaluated.
Noise Removal using Spatial Filters
Noise Removal using Spatial Filters
• Spatial filters can be used to remove various types of noise in digital
images.
• These spatial filters typically operate on small neighborhood, between
3x3 to 11x11.
• Use the degradation model defined before, assume h(r,c) causes no
degradation.
• Therefore, corruption on the image is only caused by additive noise,
n(r,c).
- d(r,c) = I(r,c) + n(r,c)
• There are two primary categories of spatial filters for noise removal.
-Order filters: arrange the pixels from smallest to largest and select
the “correct” value.
-Mean filters: calculate the average value.
• The mean filters work best with gaussian or uniform noise.
• The order filters work best with salt-and-pepper, negative exponential,
or Rayleigh noise.
• The mean filters are essentially low pass filters:
– They tend to blur the edges or details.
Spatial Filtering Process
Spatial Filtering Process
Origin x
*
Original Image Filter (w)
Simple 3*3 Pixels
e Filter 3*3
Neighbourhood
eprocessed = o*e +
k*a + l*b + m*c +
y n*d + p*f +
Image f (x, y)
q*g + r*h + s*i
Smoothing Spatial Filtering
Smoothing Spatial Filtering
Origin x
104 100 108 1
/9 1
/9 1
/9
99 106 98
95 90 85
* 1
1
/9
/9
1
1
/9
/9
1
1
/9
/9
/9 1100
1
104 /9 1108
/9
Original Image Filter
Simple 3*3 /9 106
1
99 1
/9 198
/9
Smoothing 3*3 Pixels
Neighbourhood /9 190
1
95 /9 185
/9 Filter
e = 1/9*106 +
1
/9*104 + 1/9*100 + 1/9*108 +
1
/9*99 + 1/9*98 +
y Image f (x, y)
1
/9*95 + 1/9*90 + 1/9*85
= 98.3333
Order Filters
Order Filters
• The order filters are nonlinear filters:
– The results are sometimes unpredictable.
• In general, there is a tradeoff between preservation of image detail
and noise elimination.
• In practical applications, a good approach is to use an adaptive filter (a
filter that can adapt itself to the underlying pixel values).
• Order filters are based on a specific type of image statistics called
order statistics.
– Order statistics is a technique that arranges all the pixels in
sequential order, based on gray-level value.
– The placement of the value within this ordered set is referred to as
the rank.
Order Filters
Order Filters
• Given an NxN window, the pixel values can be ordered from smallest to
largest as follows:
– I1 I2 I3..... IN2
– Where {I1,I2,I3,.....,IN2} are the gray-level values of the subset of
pixels in the image, that are in the NxN window.
• Different types of order filters select different values from the
ordered pixel list.
• Median filter:
– Select the middle pixel value from the ordered set.
– Used to remove salt-and-pepper noise.
• Maximum filter:
– Select the highest pixel value from the ordered set.
– Remove pepper-type noise.
Median Filter: Works
Median Filter: Works
Moving
Degraded Window
image
Sorted
Salt noise Array
Pepper noise
Filter output
.Therefore, it’s rare that the noise pixel will be a median value
Order Filters
Order Filters
• Minimum filter:
– Select the lowest pixel value from the ordered set.
– Remove salt-type noise.
• As the size of the window gets bigger, the more information loss occurs.
– With windows larger than about 5x5, the image acquires an artificial,
“painted”, effect.
Mask 9x9
• Order filters can also be defined to select a specific pixel rank within the
ordered set.
– For example, we may find the second highest value is the better choice than
the maximum value for certain pepper noise.
– This type of ordered selection is application specific.
• Minimum filter tend to darken the image and maximum filter tend to brighten
the image.
Order Filters
Order Filters
• Midpoint filter:
– Average of the maximum and minimum within the window.
– Useful for removing gaussian and uniform noise.
I1I 2
= Midpoint 2
N
contra-harmonic filter
Mask size=3; order= 0
pepper noise
Probability =.04
Result of contra-harmonic filter
Mask size = 3; order = 0
Result of harmonic filter Image with salt noise Result of harmonic filter
Mask size = 3 Probability=.04 Mask size = 3
Mean Filters
Mean Filters
• Yp mean filter: 1
= Yp Mean P
d(r,c)P
(r,c)w N
2
– Remove salt noise for negative values of P.
– Remove pepper noise for positive values of P.
Adaptive Filters
Adaptive Filters
• An adaptive filter alters its basic behavior as the image is processed.
– It may act like a mean filter on some parts of the image and a
median filter on other parts of the image.
• The typical character used to determine the filter behavior are the
local image characteristics.
– Measured by local gray-level statistics.
Adaptive Filters
Adaptive Filters
• The minimum mean-square error (MMSE) filter is a good example
of an adaptive filter.
d
(
r,
c)n
d
(
r,
c)
m(
2
r
,c
)
= MMSE 2 l
l
– σn2 = noise variance.
– σl2 = local variance (in the window).
– ml = local mean (average in the window).
k k 3 2 1 9 8 7
g [i , j ] h [ u ,v ] f [ i u , j v ] 7 8 9
u k v k 6 5 4 6 5 4 4 5 6
9 8 7 3 2 1 1 2 3
Imnoise
Add noise to Image
Mean
J = imnoise(I,type)
J = imnoise(I,type,parameters)
J = imnoise(I,'gaussian',m,v) variance
J = imnoise(I,'localvar',V)
J = imnoise(I,'localvar',image_intensity,var)
J = imnoise(I,'poisson')J = imnoise(I,'salt & pepper',d)
J = imnoise(I,'speckle',v)
I = imread('eight.tif');
;J = imnoise(I,'salt & pepper',0.02)
figure, imshow(I)
figure, imshow(J)
Imfilter
N-D filtering of multidimensional images
B = imfilter(A,H)
B = imfilter(A, H, option1, option2,...)