Lecture 6: Image Restoration
Computer Vision In MATLAB
By. Assist. Prof. Ielaf O.Abdul Majjed
2022-2023
Image Restoration
Image restoration attempts to reconstruct or recover an image that has been
degraded by a degradation phenomenon. Thus, restoration techniques are oriented
toward modeling the degradation and applying the inverse process in order to
recover the original image. As in image enhancement, the ultimate goal of
restoration techniques is to improve animage in some predefined sense.
Restoration Filters are the type of filters that are used for operation of noisy
image and estimating the clean and original image. It may consists of processes
that are used for blurring or the reverse processes that are used for inverse of blur.
Filter used in restoration is different from the filter used in enhancement process.
Like enhancement techniques, restoration techniques can be performed in the
spatial domain and frequency domain. For example, noise removal is applicable
using spatial domain filters whereas deblurring is performed using frequency
domain filters because image blur are difficult to approach in the spatial domain
using small masks.
A Model of Image Degradation & Restoration
Image degradation is a process that acts on an input image f(x,y) through a
degradation function H and an additive noise η(x,y). It results in a degraded image
g(x,y) such that: 𝑔(𝑥, 𝑦) = ℎ(𝑥, 𝑦) ∗ ƒ(𝑥, 𝑦) + 5(𝑥, 𝑦)
where h(x,y) is the spatial representation of the degradation function and the symbol
“*” indicates convolution.
Note that we only have the degraded image g(x,y). The objective of restoration is to
obtain an estimate ƒ^(𝑥, 𝑦) of the original image. We want the estimate to be as
close as possible to the original input image and, in general, the more we know
about H and η, the closer ƒ^(𝑥, 𝑦) willbe to f(x, y).
A model of the image degradation/restoration process
In the frequency domain, this model is equivalent to:
𝐺(𝑢, 𝑣) = 𝐻(𝑢, 𝑣)𝐹(𝑢, 𝑣) + 𝑁(𝑢, 𝑣)
Noise and its characteristics
Noise in digital images arises during:
 Acquisition: environmental conditions (light level & sensor temperature), and type
of cameras
 and/or transmission – interference in the transmission channel.
To remove noise we need to understand the spatial characteristics of noise and its
frequency characteristics. Generally, spatial noise is assumed to be independent of
position in an image and uncorrelated to the image itself (i.e. there is no correlation
between pixel values and the values of noise components).
Noise Models
The statistical behavior of gray-level values in the degraded image's noise
component describes spatial noise. Noise may be represented mathematically as a
random variable with a specified probability distribution function (PDF). Examples
of important noise models include:
 Gaussian Noise
 Rayleigh Noise
 Gamma Noise
 Exponential Noise
 Uniform Noise
 Impulse (Salt & Pepper) Noise
% For adding various kind of noise
clear; close all; clc;
I =im2double(rgb2gray(imread('peppers.png')));
imshow(I);
title("Original image");
figure,
% adding salt and pepper noise
s = imnoise(I, "salt & pepper", 0.20);
imshow([I s])
title("Salt and Pepper noise");
% adding Gaussian noise
g = imnoise(I, "gaussian", 0.20);
figure,
imshow([I g])
title("Gaussian noise");
%%% adding raylrnd noise
ra=raylrnd(I);
imshow([I ra])
title("Raylrnd noise");
figure,
% adding Speckle noise
sp = imnoise(I, "speckle", 0.20);
imshow([I sp])
title("Speckle noise");
%%% add random valued impulse noise
figure,
I = im2double(rgb2gray(imread('peppers.png')));
p = 0.2; % p between 0 and 1
Ir = (I + p*rand(size(I)))/(1+p);
title("random valued impuls noise");
imshow([I Ir])
To determine the noise model in a noisy image, one may select a relatively small
rectangular sub-image of relatively smooth region. The histogram of the sub-image
approximates the probability distribution of the corrupting model of noise.
(a) (b) (c)
(d) (e) (f)
(a) Gaussian noisy image. (b) sub-image extracted from a. (c) histogram of b
(d) Rayleigh noisy image. (e) sub-image extracted from d. (f) histogram of e
Spatial filtering is the method of choice in situations when only additive noise is
present. Spatial filters that designed to remove noise include:
1.Order Statistics Filters: e.g. Min, Max, & Median
2.Adaptive Filters : e.g. adaptive median filter
Order-Statistics Filters
1. Median filter: The best known order-statistic filter is the median filter, which
replaces the value of a pixel by the median of the intensity levels in the
neighborhood of the pixel. They provide excellent noise-reduction capabilities,
with less blurring than linear smoothing filters if similar size.
2. Max and min filters:
Min filter: This filter is useful for finding the
darkest points in an image. Also, it reduces salt
noise as a result of the min operation.
Max filter: This filter is useful for finding the
brightest points in an image. Also, because
pepper noise has very low values, it is reduced
by this filter as a result of the max operation
Adaptive Filters
The previous spatial filters are used no matter how the image changes locally.
Adaptive filters change how they work based on statistical parameters in the mask
region. So, adaptive filters are better than the ones that don't change.
Adaptive median filter
Adaptive median filtering can handle impulse noise with
probabilities even larger than these.The adaptive median
filter aims to replace f(x,y) with the median of a
neighborhood up to a specified size as long as the
median is different from the max and min values but
f(x,y)=min or f(x,y)=max.
Otherwise, f(x,y) is not changed.
From this example, we find that the adaptive median
filter has three main purposes:
1.to remove salt-and-pepper (impulse) noise.
2.to provide smoothing of other noise that may not be impulsive.
3.to reduce distortion, such as excessive thinning or thickening of object boundaries.
(a)
(a) (c)
(a) Image corrupted by salt&pepper noise with density 0.25. (b) Result obtainedusing a 7×7
median filter. (c) Result obtained using adaptive median filter with Smax = 7.

Lecture 6-2023.pdf

  • 1.
    Lecture 6: ImageRestoration Computer Vision In MATLAB By. Assist. Prof. Ielaf O.Abdul Majjed 2022-2023
  • 2.
    Image Restoration Image restorationattempts to reconstruct or recover an image that has been degraded by a degradation phenomenon. Thus, restoration techniques are oriented toward modeling the degradation and applying the inverse process in order to recover the original image. As in image enhancement, the ultimate goal of restoration techniques is to improve animage in some predefined sense. Restoration Filters are the type of filters that are used for operation of noisy image and estimating the clean and original image. It may consists of processes that are used for blurring or the reverse processes that are used for inverse of blur. Filter used in restoration is different from the filter used in enhancement process. Like enhancement techniques, restoration techniques can be performed in the spatial domain and frequency domain. For example, noise removal is applicable using spatial domain filters whereas deblurring is performed using frequency domain filters because image blur are difficult to approach in the spatial domain using small masks.
  • 3.
    A Model ofImage Degradation & Restoration Image degradation is a process that acts on an input image f(x,y) through a degradation function H and an additive noise η(x,y). It results in a degraded image g(x,y) such that: 𝑔(𝑥, 𝑦) = ℎ(𝑥, 𝑦) ∗ ƒ(𝑥, 𝑦) + 5(𝑥, 𝑦) where h(x,y) is the spatial representation of the degradation function and the symbol “*” indicates convolution. Note that we only have the degraded image g(x,y). The objective of restoration is to obtain an estimate ƒ^(𝑥, 𝑦) of the original image. We want the estimate to be as close as possible to the original input image and, in general, the more we know about H and η, the closer ƒ^(𝑥, 𝑦) willbe to f(x, y). A model of the image degradation/restoration process In the frequency domain, this model is equivalent to: 𝐺(𝑢, 𝑣) = 𝐻(𝑢, 𝑣)𝐹(𝑢, 𝑣) + 𝑁(𝑢, 𝑣)
  • 4.
    Noise and itscharacteristics Noise in digital images arises during:  Acquisition: environmental conditions (light level & sensor temperature), and type of cameras  and/or transmission – interference in the transmission channel. To remove noise we need to understand the spatial characteristics of noise and its frequency characteristics. Generally, spatial noise is assumed to be independent of position in an image and uncorrelated to the image itself (i.e. there is no correlation between pixel values and the values of noise components). Noise Models The statistical behavior of gray-level values in the degraded image's noise component describes spatial noise. Noise may be represented mathematically as a random variable with a specified probability distribution function (PDF). Examples of important noise models include:  Gaussian Noise  Rayleigh Noise  Gamma Noise  Exponential Noise  Uniform Noise  Impulse (Salt & Pepper) Noise
  • 5.
    % For addingvarious kind of noise clear; close all; clc; I =im2double(rgb2gray(imread('peppers.png'))); imshow(I); title("Original image"); figure, % adding salt and pepper noise s = imnoise(I, "salt & pepper", 0.20); imshow([I s]) title("Salt and Pepper noise"); % adding Gaussian noise g = imnoise(I, "gaussian", 0.20); figure, imshow([I g]) title("Gaussian noise"); %%% adding raylrnd noise ra=raylrnd(I); imshow([I ra]) title("Raylrnd noise"); figure, % adding Speckle noise sp = imnoise(I, "speckle", 0.20); imshow([I sp]) title("Speckle noise"); %%% add random valued impulse noise figure, I = im2double(rgb2gray(imread('peppers.png'))); p = 0.2; % p between 0 and 1 Ir = (I + p*rand(size(I)))/(1+p); title("random valued impuls noise"); imshow([I Ir])
  • 6.
    To determine thenoise model in a noisy image, one may select a relatively small rectangular sub-image of relatively smooth region. The histogram of the sub-image approximates the probability distribution of the corrupting model of noise. (a) (b) (c) (d) (e) (f) (a) Gaussian noisy image. (b) sub-image extracted from a. (c) histogram of b (d) Rayleigh noisy image. (e) sub-image extracted from d. (f) histogram of e
  • 7.
    Spatial filtering isthe method of choice in situations when only additive noise is present. Spatial filters that designed to remove noise include: 1.Order Statistics Filters: e.g. Min, Max, & Median 2.Adaptive Filters : e.g. adaptive median filter Order-Statistics Filters 1. Median filter: The best known order-statistic filter is the median filter, which replaces the value of a pixel by the median of the intensity levels in the neighborhood of the pixel. They provide excellent noise-reduction capabilities, with less blurring than linear smoothing filters if similar size. 2. Max and min filters: Min filter: This filter is useful for finding the darkest points in an image. Also, it reduces salt noise as a result of the min operation. Max filter: This filter is useful for finding the brightest points in an image. Also, because pepper noise has very low values, it is reduced by this filter as a result of the max operation
  • 8.
    Adaptive Filters The previousspatial filters are used no matter how the image changes locally. Adaptive filters change how they work based on statistical parameters in the mask region. So, adaptive filters are better than the ones that don't change. Adaptive median filter Adaptive median filtering can handle impulse noise with probabilities even larger than these.The adaptive median filter aims to replace f(x,y) with the median of a neighborhood up to a specified size as long as the median is different from the max and min values but f(x,y)=min or f(x,y)=max. Otherwise, f(x,y) is not changed. From this example, we find that the adaptive median filter has three main purposes: 1.to remove salt-and-pepper (impulse) noise. 2.to provide smoothing of other noise that may not be impulsive. 3.to reduce distortion, such as excessive thinning or thickening of object boundaries. (a) (a) (c) (a) Image corrupted by salt&pepper noise with density 0.25. (b) Result obtainedusing a 7×7 median filter. (c) Result obtained using adaptive median filter with Smax = 7.