# Image Restoration and Reconstruction and Geometric Transformations

A Model of Image Degradation/Restoration Process
1. The degradation process is modeled as a degradation function that, together with an additive noise term, operates
on an input image f(x,y) to produce a degraded image
g(x,y):
g(x,y) = H[f(x,y) + n(x,y)]

3. If H is linear, spatially invariant process, degraded image in spatial
domain is given as:
g(x,y) = h(x,y)*f(x,y) + n(x,y)
4. Frequency domain representation of a degraded image is given as:
G(u,v) = H(u,v) F(u,v) + N(u,v)

Noise Models
1. Adding noise with function imnoise:
g = imnoise(f, type, parameters)
2. Generating spatial random noise with a specified distribution:
a. Spatial noise values are random numbers, characterized by a
probability density function (PDF) or cumulative distribution function
(CDF).
b. Random number with Rayleigh CDF is generated by using the
expression:
R = a + sqrt(b*log(1 – rand (M, N)))
3. Periodic Noise:
a. Electrical and/or electromechanical interference during image
acquisition is the cause of periodic noise in an image.
b. Periodic noise is typically handled in an image by filtering in the
frequency domain.
c. The model of periodic noise is a 2D sinusoid with equation:
r(x,y) = A sin [2 pi u0 (x + Bx)/M + 2 pi v0 (y + By)/N]
4. Estimating noise parameters:
a. The function statmoments computes the mean and central moments
upto order n, and returns them in row vector v, having syntax:
[v, unv] = statmoments (p, n)
b. The function roipoly is used to generate polygon region of interest,
having syntax:
B = roipoly(f, c, r)
c. The following construct can be used to obtain the binary image and
a list of the polygon vertices.
[B, c, r] = roipoly(. . .)
d. histroi command is used to compute the histogram of an ROI in an
image.
[p, npx] = histroi (f, c, r)

Spatial Noise Filters
1. The function spfilt performs filtering in the spatial domain with any of the
filters, having syntax:
f = spfilt (g, type, m, n, parameter)
2. The linear combination of the inputs can be computed by using the
function imlincomb, having syntax:
B = imlincomb (c1, A1, c2, A2, . . . , ck, Ak)

1. Spatial filters are applied to an image without considering the changes in
image characteristics from one location to another.
2. The results can be improved by using filters capable of adapting their
behaviour depending on the characteristics of the image in the area
being filtered.
3. Let us consider an adaptive median filter having subimage, Sxy, centered
at location (x,y); minimum intensity value, Zmin, in Sxy; maximum intensity
value, Zmax, in Sxy; median of the intensity values, Zmed, in Sxy; and
intensity value, Zxy, at coordinates (x,y).
4. There are two levels in which the adaptive median filtering algorithm
works.
a. Level A:
If Zmin < Zmed < Zmax, go to level B
Else increase the window size
If window size <= Smax, repeat level A
Else output Zmed
b. Level B:
If Zmin < Zxy < Zmax, output Zxy
Else output Zmed
5. The command adpmedian is used to implement this algorithm, having
syntax:

1. The typical approach to determine the nature of the degradation in the
image is to experiment by generating PSFs and testing the results with
various restoration algorithms.
2. Another approach is mathematical modeling of PSF.
3. Moreover, blind deconvolution can be used to infer the PSF when no
information of PSF is available.
4. PSFs can be modeled by using imfilter and fspecial functions.
5. Image blur is one of the degradations encountered in restoration
problems.
6. Image blur can be modeled by using fspecial function as:
PSF = fspecial(‘motion’, len, theta)
7. The function imfilter is used to create a degraded image with PSF as:
g = imfilter(f, PSF, ‘circular’)
8. After that the degraded image model can be completed by adding noise
as:
g = g + noise
9. Function checkerboard is used to generate the test pattern which is
useful in comparing using same image or test pattern, having syntax:
C = checkerboard (Np, M, N)

Wiener Filtering
1. Function deconvwnr is used to implement Wiener filtering in IPT.
2. There are three syntax forms for the same:
fr = deconvwnr (g, PSF)
fr = deconvwnr (g, PSF, NSPR)
fr = deconvwnr (g, PSF, NACORR, FACORR)
3. If the discrete fourier transform introduces ringing in the restored image,
function edgetaper is used prior to calling deconvwnr to blur the edges
of the input image, having syntax:
J = edgetaper (I, PSF)

Constrained Least Squares (Regularized) Filtering
1. Function deconvreg is used to implement constrained least squares
filtering in IPT, having syntax:
fr = deconvreg (g, PSF, NOISEPOWER, RANGE)
2. If the discrete fourier transform introduces ringing in the restored image,
function edgetaper is used prior to calling deconvreg to blur the edges
of the input image, having syntax:
J = edgetaper (I, PSF)

Iterative Nonlinear Restoration Using the Lucy-Richardson Algorithm
1. Function deconvlucy is used to implement L-R algorithm in IPT, having
syntax:
fr = deconvlucy (g, PSF, NUMIT, DAMPAR, WEIGHT)
2. If the discrete fourier transform introduces ringing in the restored image,
function edgetaper is used prior to calling deconvlucy to blur the edges
of the input image, having syntax:
J = edgetaper (I, PSF)

Geometric Spatial Transformations
1. Spatial transformations in IPT are represented by using tform structure.
2. This structure can be created by using maketform function, having
syntax:
tform = maketform (transform_type, transform_parameters)
3. Spatial transformations can be applied to an image either by using
forward mapping or inverse mapping.
4. The function imtransform uses inverse mapping, having syntax:
g = imtransform (f, tform, interp)

Image Registration
1. Image registration methods align two images of the same scene.
2. IPT supports image registration based on the use of control points, also
known as tie points.
3. IPT function cp2tform can be used to fit a specified type of spatial
transformation after choosing a sufficient number of control points.
4. The toolbox includes a GUI for the interactive selection of control points
on a pair of images.

Transformation types supported by cp2tform and maketform.