You are on page 1of 94

` PART A

UNIT 1

FUNDAMENTALS OF DIP

INTRODUCTION

DIGITAL IMAGE PROCESSING

• Digital image processing refers to processing a digital image by means of a digital


computer.

• An image is defined as two dimensional light intensity functions.

• It is denoted as f(x ,y), where ‘x’ and ‘y’ are spatial co-ordinates and amplitude of ‘f’
at any pair of co-ordinates(x, y) is called intensity of the image at that point.

• Digital image is composed of finite number of elements, each having a particular


location and value. These elements are called pixels or picture elements.

FUNDAMENTAL STEPS IN DIGITAL IMAGE PROCESSING (DIP)

In general the image processing methods classified as

(i) the methods whose input and output are images and
(ii) the methods whose inputs may be images and outputs are attributes
extracted from those images.

The fundamental steps in image processing can be explained as given below:

• Image acquisition system.

• Image enhancement.

• Image restoration.

• Colour image processing.

• Image compression.

• Segmentation.

• Representation.

• Recognition.

• Interpretation.
Image Acquisition.

• First step in digital image processing is image capturing.

• If the output is not in digital form, it is converted to digital form using analog to
digital converter.

• Camera used to acquire the image can be monochrome or colour TV camera.

• After digital image is obtained, next step is pre-processing

Image Pre-processing

• It improves the quality of the image.

• It is divided into two parts:

Image Enhancement

Image Restoration

Image Enhancement

• Principal objective is to process an image so that result is more suitable than original
image.

• To improve the quality the contrast level of the picture is adjusted.

Image Restoration

• It deals with improving the appearance of an image.

• Image restoration is objective while enhancement is subjective.

• Enhancement is based on human preferences while restoration is based on


mathematical or probabilistic models of image degradation.

• In this method the original image is obtained by removing noise.

• Ultimate goal of a restoration technique is to improve quality of the image.

Colour Image Processing

• Based on the gray level, colours will be added to the picture.

• Colour is used as the basis for extracting features of interest in an image.

Wavelets
• These are the foundations for representing images in various degrees of resolution.

• Used for image data compression and for pyramidal representation, in which images
are sub divided into smaller regions.

Image Compression

• It deals with techniques for reducing the storage required to save an image or the
bandwidth require to transmit it.

• In this process number of bits is reduced to store the image data.

• Many encoding techniques are used.

Segmentation

• Process of segmentation is partitioning of input image into constituent parts or


objects.

• Key role of segmentation is to extract boundary of object from the background.

Representation and Description System

• Output segmentation stage is raw pixel data consisting either boundary of a region or
all the points in the region.

• Representation and description is the process of converting raw pixel data to a form
suitable for computer processing.

• Description is also called feature selection.

Recognition and Interpretation

• Recognition is a process of assigning a label to an object based on the information


provided by the descriptors.

• Interpretation is nothing but assigning meaning to the recognized object.

Knowledge Base

• Knowledge about the problem domain is coded into the image processing system in
the form of knowledge base.

• Each module will interact with the knowledge base to decide about the appropriate
technique for the right application

A Simple Image Model


The images in two dimensional functions is of the form f(x,y).
The value or amplitude of f at spatial co-ordinates (x,y)is a positive scalar quantity
F(x,y) is characterized by two components:

(1) Amount of source illumination incident on the scene being viewed, i(x,y).
(2) Amount of illumination reflected by the objects in the scene,r(x,y).
F(x,y) = i(x,y)r(x,y)

Concept of Gray Level:

It is the brightness of a pixel. The value associated with a pixel representing it’s
lightness from black to white. Usually defined as, a value from 0 to 255, with 0 being
black and 255 being white.
Optical Illusions

Concept in Image Sampling and Quantization:


Formation of digital image from a continuous image basically involves two steps.
They are Sampling and Quantization. An image may be continuous with respect to x
and y coordinates and also in amplitude. Digitizing the coordinate values is called
sampling whereas digitizing the amplitude values is called quantization. Sampling is
done by taking equally spaced samples along the line AB. The location of each sample
is given a vertical tick mark in the bottom part of the figure-3.
The set of these discrete locations gives the sampled function. However, the values of
the samples still span a continuous range of gray-level values. In order to form a
digital function, the gray-level values also must be converted into discrete quantities.
The right side of the figure-3 shows the gray-level scale divided into eight discrete
levels ranging from black to white. The vertical tick marks indicates the specific value
assigned to each of the eight gray levels. The continuous gray levels are quantized
simply by assigning one of the eight discrete gray levels to each sample. The
assignment is made depending on the vertical proximity of a sample to a vertical tick
mark. Starting from the top of the image and carrying out this procedure line by line
produces a 2D digital image.

[ ]
128 127 1 . .
255 . . . .
120 . . . .
. . . . .
. . . . .

f(x,y)
Gray Level

Relationship between Pixels:

A pixel p at coordinates (x, y) has four horizontal and vertical neighbours whose
coordinates are given by (x+1, y), (x-1, y), (x, y+1), (x, y-1). This set of pixels called
the 4-neighbors of p, is denoted by N4(p). Each pixel is a unit distance from (x, y), and
some of the neighbors of p lie outside the digital image if (x, y) is on the border of the
image.
The four diagonal neighbors of p have coordinates (x+1, y+1), (x+1, y-1), (x-1, y+1),
(x-1, y-1) and are denoted by ND(p). These points, together with the 4-neighbors, are
called the 8- neighbors of p, denoted by N8(p). As before, some of the points in ND(p)
and N8(p) fall outside the image if (x, y) is on the border of the image.

Imaging Geometry:
The basic transformations in image geometry are scaling, translation and rotation.
Here all transformation is expressed in 3D coordinate system (x, y, z).
1. Translation:
The point (x, y, z) is translated to new location with coordinates (x0, y0, z0) which
can be done by translation i.e.,
x*=x0+x
y*=y0+y
z*=z0+z
Therefore, x*, y* and z* are the coordinates of new location. The above equations
are written in the form of matrix as:

2. Scaling:

The scaling of coordinates (x, y, z) are represented by Sx, Sy and Sz. Then scaling
transformation matrix is

3. Rotation:

Rotation of arbitrary requires three steps. They are the arbitrary point is
translated to origin, performs rotation and translates the point back to its current
position.Rotation of a point about x-axis by angle α is denoted by Rα .Similar
transformations are performed for y and z axis at an angle of β and θ respectively.

Color Image Processing

Spectrum of White Light: In1666 Sir Isaac Newton, 24 year old, discovered white
light spectrum.There are 2 types of color image processes

1. Pseudo color image process: Assigning colors to gray

values based on a specific criterion. Gray scale images to be processed

may be a single image or multiple images such as multispectral images

2. Full color image process: The process to manipulate realcolor images such
as color photographs.
Electromagnetic Spectrum

Visible light wavelength: from around 400 to 700 nm


1. For an achromatic (monochrome) light source,
there is only 1 attribute to describe the quality: intensity
2. For a chromatic light source, there are 3 attributes to describe
the quality:
Radiance = total amount of energy flow from a light source (Watts)
Luminance = amount of energy received by an observer (lumens)
Brightness = intensity

Sensitivity of Cones in the Human Eye

There are 6-7 millions conesin a human eye

- 65% sensitive to Red light

- 33% sensitive to Green light

- 2 % sensitive to Blue light


Primary colors:Defined CIE in 1931

Red = 700 nm

Green = 546.1nm

Blue = 435.8 nm

Primary and Secondary Colors

Additive primary colors: RGBuse in the case of light sourcessuch as color monitors.

RGB add together to get white

Subtractive primary colors: CMYuse in the case of pigments inprinting devices

White subtracted by CMY to getBlack

Color Characterization

Hue: dominant color corresponding to a dominant

wavelength of mixture light wave

Saturation: Relative purity or amount of white light mixed

with a hue (inversely proportional to amount of whitelight added)

Brightness: Intensity

Hue+ Saturation = chromaticity.

Amount of red (X), green (Y) and blue (Z) to form any particularcolor is called tristimulus
Trichromatic coefficients:

X
x=
X +Y +Z

Y
y=
X +Y +Z

Z
z=
X +Y + Z

x+ y+ z=1
CIE Chromaticity Diagram

RGB Color Model

 Purpose of color models is to facilitate the specification of colors in some


standard.RGB color models is based on Cartesiancoordinate system.
 Each colour appears in its primary spectral components of red,green and blue.
 In this model, the gray scale (points of equal RGB values)extends from black to
white along the line joining these two points.
 Colours values are assumed to be normalized ,ie cube is the unit cube.All values
of R,G and B are assumed to be in the range (0,1).
 Full-color image is used to denote a 24-bit RGB color Model.
 Total no: of colours in a 24-bit RGB image is (28)3=16,777,216.
 An RGB image in which each of reed, green and blue images is an 8-bit
image,then each RGB colour pixel is said to have a depth of 24 bits.

Safe RGB Colors


Safe RGB colors: a subset of RGB colors.

There are 216 colors common in most operating systems

RGB Safe-color Cube

The RGB Cube is divided into6 intervals on each axis to achievethe total 6 3 = 216 common colors.
However, for 8 bit color representation, there are the total256 colors. Therefore, the remaining40
colors are left to OS.

CMY and CMYK Color Models

C = Cyan

M = Magenta

Y = Yellow

K = Black

[ ][][ ]
C 1 R
M =1 −G
Y 1 B
HSI Color Model

RGB, CMY models are not good for human interpreting.HSI (Hue.Saturation,Intensity)color model
decouples the intensity component from the color carrying information(hue and saturation) in a color
image. Thus HSI Model is an ideal tool for developing image processing algorithms based on colour
descriptions that are natural and intuitive to humans.

Hue: Dominant color

Saturation: Relative purity (inversely proportional

to amount of white light added)Color carrying information

Intensity: Brightness

Hue and Saturation on Color Planes

1 .A dot is the plane is an arbitrary color

2. Hue is an angle from a red axis.

3. Saturation is a distance to the point.

All points contained in the plane segment by the intensity axis and boundaries of the
cube have same hue. All colours generated by three colours lie in the triangle defined by
those colors.If two of those points are black &white, third is a colour point, all points on the
triangle have same hue because black and white components cannot change hue.
Intensity is given by a position on the vertical axis
Example: HSI Components of RGB Cube

RGB CUBE

HUE SATURATION INTENSITY


Converting Colors from RGB to HSI

H= {θ360−θ if B≤G
if B>G

 1 
  ( R  G )  ( R  B )  
  cos 1  2
1/ 2 
 ( 
R  G ) 2
 ( R  B )( G  B )  
 
1
I= ( R+G+ B )
3
3
S=1−
R+G+B

Example: HSI Components of RGB Colors


Converting Colors from HSI to RGB

RG sector:

0≤H< 120

R=I 1+
[ S cos H

cos (60 −H ) ]
B=I (1−S )

G=1−( R+B)
BR sector

240≤H ≤360

H=H −240

B=I 1+
[ S cos H

cos(60 −H ) ]
G=I (1−S )

R=1−(G+B)

GB sector

120≤H <240

H=H −120

R=I (1−S )

G=I 1+
[ S cos H

cos(60 −H ) ]
B=1−( R+G)
UNIT 2

IMAGE TRANSFORMS

INTRODUCTION

 Image transforms are used in image processing and image analysis.


 Transform is basically a mathematical tool ,which allows us to move from one
domain to another domain (time domain to frequency domain)
 Reason to migrate from one domain to another domain is to perform the task at hand
in an easier manner.
Two reasons for transforming an image from one representation to another:
 Transformation may isolate critical components of the image pattern
so that they are directly accessible for analysis.
 Transformation may place image data in a more compact form so that
they can be stored and transformed efficiently.

Image Transforms are useful for:

 Fast computation of convolution and correlation.


 Transforms change the representation of a signal by projecting it into a set
of basic functions.
 Transforms do not change information content present in the signal.
 Most of the image transforms like Fourier transform ,discrete cosine
transform, wavelet transform etc gives information about the frequency
content in an image. All transforms will not give frequency domain
information.
 Transforms play a significant role in various image processing
applications such as image analysis, image enhancement, and image
filtering and image compression.

NEED FOR TRANSFORM

Transform is basically a mathematical tool for representing a signal. Need for transform
is given as follows:

(1) Mathematical Convenience

Every action in time domain will have an impact in the frequency domain.

CONVOLUTION IN TIME DOMAIN MULTIPLICATION IN FREQUENCY DOMAIN

(2) To Extract more information


Transforms allows us to extract more relevant information.

CLASSIFICATION OF IMAGE TRANSFORMS

Classified on the basics of the nature of the basic function

(1)Transforms with orthogonal basics function

(2)Transforms with non-sinusoidal orthogonal basics function

(3) Transforms whose basics function depends on the statistics of o/p data.

(4)Directional transform, transforms whose basic function are capable of


representing directional information present in an image.

Powerful transform with orthogonal sinusoidal basic function is Fourier transform.

Transform whose basic function is sinusoidal in nature include Fourier, discrete cosine
&discrete sine transform.

Used in the field of image compression is discrete cosine transform.

Non-sinusoidal in nature is haar transform which is the simplest example of


wavelet transform.

FOURIER TRANSFORM

Fourier Transform is an important image processing tool which is used to decompose an


image into its sine and cosine components. The output of the transformation represents the
image in the Fourier frequency domain, while the input image is the spatial domain
equivalent. In the Fourier domain image, each point represents a particular frequency
contained in the spatial domain image.

The Fourier Transform is used in a wide range of applications, such as image analysis, image
filtering, image reconstruction and image compression.

The DFT is the sampled Fourier Transform and therefore does not contain all frequencies
forming an image, but only a set of samples which is large enough to fully describe the
spatial domain image. The number of frequencies corresponds to the number of pixels in the
spatial domain image, i.e. the image in the spatial and Fourier domain are of the same size.

For a square image of size N×N, the two-dimensional DFT is given by:
where f(a,b) is the image in the spatial domain and the exponential term is the basis function
corresponding to each point F(k,l) in the Fourier space. The equation can be interpreted as:
the value of each point F(k,l) is obtained by multiplying the spatial image with the
corresponding base function and summing the result.The basic functions are sine and cosine
waves with increasing frequencies, i.e. F(0,0) represents the DC-component of the image
which corresponds to the average brightness and F(N-1,N-1) represents the highest
frequency.In a similar way, the Fourier image can be re-transformed to the spatial domain.
The inverse Fourier transform is given by:

Note the normalization term in the inverse transformation. This normalization is


sometimes applied to the forward transform instead of the inverse transform, but it should not
be used for both.$$

To obtain the result for the above equations, a double sum has to be calculated for each image
point. However, because the Fourier Transform is separable, it can be written as

where

Using these two formulas, the spatial domain image is first transformed into an intermediate
image using N one-dimensional Fourier Transforms. This intermediate image is then
transformed into the final image, again using None-dimensional Fourier Transforms.
Expressing the two-dimensional Fourier Transform in terms of a series of 2N one-
dimensional transforms decreases the number of required computations.

Even with these computational savings, the ordinary one-dimensional DFT has
complexity. This can be reduced to if we employ the Fast Fourier
Transform (FFT) to compute the one-dimensional DFTs. This is a significant improvement, in
particular for large images. There are various forms of the FFT and most of them restrict the
size of the input image that may be transformed, often to where n is an integer. The
mathematical details are well described in the literature.

The Fourier Transform produces a complex number valued output image which can be
displayed with two images, either with the real and imaginary part or
with magnitude and phase. In image processing, often only the magnitude of the Fourier
Transform is displayed, as it contains most of the information of the geometric structure of
the spatial domain image. However, if we want to re-transform the Fourier image into the
correct spatial domain after some processing in the frequency domain, we must make sure to
preserve both magnitude and phase of the Fourier image.
The Fourier domain image has a much greater range than the image in the spatial domain.
Hence, to be sufficiently accurate, its values are usually calculated and stored in float values.

Propertiesof Fourier Transform

There are a variety of properties associated with the Fourier transform and the inverse Fourier
transform. The following are some of the most relevant for digital image processing.

* The Fourier transform is, in general, a complex function of the real frequency variables. As
such the transform con be written in terms of its magnitude and phase.

* A 2D signal can also be complex and thus written in terms of its magnitude and phase.

* If a 2D signal is real, then the Fourier transform has certain symmetries.

The symbol (*) indicates complex conjugation. For real signals equation leads directly to,

* If a 2D signal is real and even, then the Fourier transform is real and even

* The Fourier and the inverse Fourier transforms are linear operations

where a and b are 2D signals (images) and and are arbitrary, complex constants.

* The Fourier transform in discrete space, ,is periodic in both and .Both
periods are

integers
DISCRETE COSINE TRANSFORM (DCT):

One dimensional signals

This is a transform that is similar to the Fourier transform in the sense that the new
independent variable represents again frequency. The DCT is defined below.
N−1
C(u )=a(u) ∑ f ( x )cos
x=0
[ (2 x+1 )uπ
2N ] , u=0,1,…,N −1

with a(u) a parameter that is defined below.

a(u )=
{ √ 1/N
√ 2/N u=1,…, N−1
u=0

The inverse DCT (IDCT) is defined below.

N−1
f (x )= ∑ a (u)C(u )cos
u=0
[ (2 x+1 )uπ
2N ]
N−1
f (x )= ∑ a (u)C(u )cos
u=0
[ (2 x+1 )uπ
2N ]
Two dimensional signals (images)

For 2-D signals it is defined as


N −1 N −1
C(u , v )=a(u)a( v ) ∑ ∑ f ( x , y )cos
x=0 y =0
[ (2 x +1)uπ
2N ] [
cos
(2 y +1 )vπ
2N ]
N−1 N −1
f (x , y )= ∑ ∑ a(u )a(v )C (u , v )cos
u=0 v=0
[ (2 x +1)uπ
2N ] [
cos
(2 y +1 )vπ
2N ]
a(u) is defined as above and u , v=0,1, …, N −1

Properties of the DCT transform

 The DCT is a real transform. This property makes it attractive in comparison to the
Fourier transform.
 The DCT has excellent energy compaction properties. For that reason it is widely used in
image compression standards (as for example JPEG standards).
 There are fast algorithms to compute the DCT, similar to the FFT for computing the DFT.
HADAMARD TRANSFORM (HT)

Definition

In a similar form as the Walsh transform, the 2-D Hadamard transform is defined as follows.

Forward

[ ]
N −1 N−1 n−1
1 ( b i ( x ) bi ( u)+b i ( y )b i ( v ) )
H (u , v )= ∑ ∑ f ( x , y ) ∏ (−1 )
N x=0 y=0 i=0 , N=2n or
n−1
N −1 N−1 ∑ ( b i ( x ) bi ( u)+b i ( y ) bi ( v ) )
1
H (u , v )=
N
∑ ∑ f ( x , y )(−1) i=0

x=0 y=0

Inverse

[ ]
N−1 N−1 n−1
1 ( b i ( x ) bi ( u)+b i ( y )b i ( v ) )
f (x , y )=
N
∑ ∑ H (u , v ) ∏ (−1 )
u=0 v=0 i=0 etc.

Properties of the Hadamard Transform

 Most of the comments made for Walsh transform are valid here.

 The Hadamard transform differs from the Walsh transform only in the order of basis
functions. The order of basis functions of the Hadamard transform does not allow the fast
computation of it by using a straightforward modification of the FFT. An extended
version of the Hadamard transform is the Ordered Hadamard Transform for which a fast
algorithm called Fast Hadamard Transform (FHT) can be applied.

 An important property of Hadamard transform is that, letting H N represent the matrix


of order N , the recursive relationship is given by the expression

H 2 N=
[ HN H N
H N −H N ]
UNIT – 3

IMAGE ENHANCEMENT IN SPATIAL DOMAIN

Image Enhancement (Spatial)

1. Improving the interpretability or perception of information in images for human


viewers
2. Providing `better' input for other automated image processing techniques

Principle Objective of Enhancement

• Process an image so that the result will be more suitable than the original image for a
specific application.

• The suitableness is up to each application.

• A method which is quite useful for enhancing an image may not necessarily be the best
approach for enhancing another images

Image Enhancement is divided into two broad categories:

Spatial Domain : (image plane)

• Techniques are based on direct manipulation of pixels in an image.

Frequency Domain :

• Techniques are based on modifying the Fourier transform of an image

• There are some enhancement techniques based on various combinations of


methods from these two categories.

Good images

• For human visual

– The visual evaluation of image quality is a highly subjective process.

– It is hard to standardize the definition of a good image.

• For machine perception

– The evaluation task is easier.

– A good image is one which gives the best machine recognition results.

A certain amount of trial and error usually is required before a particular image enhancement
approach is selected.

Spatial Domain

• Procedures that operate directly on pixels.

g(x,y) = T[f(x,y)]

where
– f(x,y) is the input image

– g(x,y) is the processed image

T is an operator on f defined over some neighborhood of (x,y)

Point Processing

• The simplest kind of range transformations are these independent of position x,y:

g = T(f)

• This is called point processing.

• Important: every pixel for himself – spatial information completely lost!

• Neighborhood = 1x1 pixel

• g depends on only the value of f at (x,y)

• T = gray level (or intensity or mapping) transformation function

s = T(r)

Where

r = gray level of f(x,y)


s = gray level of g(x,y)

Obstacle with point processingAssume that f is the clown image and T is a random
function and apply g = T(f):

• What we take from this?

1. May need spatial information

2. Need to restrict the class of transformation, e.g. assume monotonicity.

GRAY-LEVEL TRANSFORMATION FUNCTIONS

1. Linear function

– Negative and identity transformations

2. Logarithm function

– Log and inverse-log transformation

3. Power-law function

– nth power and nth root transformations.

IDENTITY FUNCTION

• Output intensities are identical to input intensities.

• Is included in the graph only for completeness

IMAGE NEGATIVES

• An image with gray level in the range[0, L-1]where L = 2n; n = 1, 2…


• Negative transformation :
s = L – 1 –r
• Reversing the intensity levels of an image produces the equivalent of a photographic
negative.
• Suitable for enhancing white or gray detail embedded in dark regions of an image,
especially when the black area dominant in size.

Original imageNegative Image : gives a better vision to analyze the image

LOG TRANSFORMATIONS

s = c log (1+r)

• c is a constant and r ³ 0

• Log curve maps a narrow range of low gray-level values in the input image into a
wider range of output levels.

Used to expand the values of dark pixels in an image while compressing the higher-level
values

Example of Logarithm:

A Fourier spectrum with values in the range 0 to 1.5 x 10 6 is shown in figure below..When
these values are scaled linearly for display in an 8- bit system, the brightest pixels will
dominate the display, at the expense of lower values of the spectrum.Effect of this dominance
is illustrated vividly by the relatively small area of the imageas shown in figure below that is
not perceived as black.

Fourier Spectrum with range = 0 to 1.5 x 10 6andResult after apply the log transformation with c = 1,
range = 0 to 6.2

INVERSE LOGARITHM TRANSFORMATIONS

• Do opposite to the Log Transformations

• Used to expand the values of high pixels in an image while compressing the darker-
level values

POWER-LAW TRANSFORMATIONS

s = crg

• c and g are positive constants

• Power-law curves with fractional values of g map a narrow range of dark input values
into a wider range of output values, with the opposite being true for higher values of
input levels.

• c = g = 1 a Identity function

• Variety of devices used for image capture, printing and display respond according to
power law. The process used to correct these power law response phenomena is called
gamma correction.
Plots of s = crgfor various values of g(c = 1 in all cases)

Why power laws are popular?

• A cathode ray tube (CRT), for example, converts a video signal to light in a nonlinear
way. The light intensity I is proportional to a power (γ) of the source voltage VS

• For a computer CRT, γ is about 2.2

• Viewing images properly on monitors requires γ-correction

Gamma Correction

• Gamma correction is important if displaying an image accurately on a computer


screen .
• Trying to reproduce colours ,the value of gamma correction not only changes the
brightness ,but also ratios of red to green to blue.
Another example: MRI

(a) a magnetic resonance image of an upper thoracic human spine with a fracture dislocation
and spinal cord impingement

– The picture is predominately dark

– An expansion of gray levels are desirable a needs g< 1

(b) Result after power-law transformation with g = 0.6, c=1

(c) transformation with g = 0.4 (best result)

(d) transformation with g = 0.3 (under acceptable level)

Effect of decreasing gamma

• When the g is reduced too much, the image begins to reduce contrast to the point
where the image started to have very slight “wash-out” look, especially in the
background.
a b
c d

Example 3:

(a) image has a washed-out appearance, it needs a compression of gray levels a needs g> 1

(b) result after power-law transformation with g = 3.0 (suitable)

(c) transformation with g = 4.0(suitable)


(d) transformation with g = 5.0(high contrast, the image has areas that are too dark, some
detail is lost)

Piecewise-Linear Transformation Functions

• Advantage:

– The form of piecewise functions can be arbitrarily complex

• Disadvantage:

– Their specification requires considerably more user input

CONTRAST STRETCHING

• Produce higher contrast than the original by

– darkening the levels below m in the original image

– Brightening the levels above m in the original image


(a)increase the dynamic range of the gray levels in the image

(b) a low-contrast image : result from poor illumination, lack of dynamic range in the
imaging sensor, or even wrong setting of a lens aperture of image acquisition
(c) result of contrast stretching: (r1,s1) = (rmin,0) and (r2,s2) = (rmax,L-1)

(d) result of thresholding

Thresholding : Produce a two-level (binary) image

GRAY-LEVEL SLICING

• Highlighting a specific range of gray levels in an image

– Display a high value of all gray levels in the range of interest and a low value
for all other gray levels.This transformation produces binary image.

– Brightens the desired range of gray levels but preserves the background and
gray level tonalities in the image.

(a) Transformation highlights range [A,B] of gray level and reduces all others to a
constant level

(b) Transformation highlights range [A,B] but preserves all other levels
BIT-PLANE SLICING

• Highlighting the contribution made to total image appearance by specific bits

• Suppose each pixel is represented by 8 bits

• Higher-order bits contain the majority of the visually significant data

• Useful for analyzing the relative importance played by each bit of the image
Examples:

An 8-bit fractal image

• The (binary) image for bit-plane 7 can be obtained by processing the input image with
a thresholding gray-level transformation.

– Map all levels between 0 and 127 to 0

– Map all levels between 129 and 255 to 255

8 bit planes
Bit-plane 7 Bit-plane 6

Bit-plane 5 Bit-plane 4 Bit-plane 3

Bit-plane 2 Bit-plane 1 Bit-plane 0

HISTOGRAM PROCESSING

• Histogram of a digital image with gray levels in the range [0,L-1] is a discrete
function

h(rk) = nk

Where

– rk : the kth gray level

– nk : the number of pixels in the image having gray level rk

– h(rk) : histogram of a digital image with gray levels rk

• Basic for numerous spatial domain processing techniques

• Used effectively for image enhancement

• Information inherent in histograms also is useful in image compression and segmentation

Normalized Histogram

• dividing each of histogram at gray level rk by the total number of pixels in the image, n
p(rk) = nk / n

• For k = 0,1,…,L-1

• p(rk) gives an estimate of the probability of occurrence of gray level rk

• The sum of all components of a normalized histogram is equal to 1

Example

Dark image:Components of histogram are concentrated on the low side of the gray scale.

Bright image:Components of histogram are concentrated on the high side of the gray
Low-contrast image:histogram is narrow and centered toward the middle of the gray scale

High-contrast image:histogram covers broad range of the gray scale and the distribution of
pixels is not too far from uniform, with very few vertical lines being much higher than the
others.

Cumulative Histograms:
HISTOGRAM EQUALIZATION

• As the low-contrast image’s histogram is narrow and centered toward the middle of
the gray scale, if we distribute the histogram to a wider range the quality of the image
will be improved.

• We can do it by adjusting the probability density function of the original histogram of


the image so that the probability spread equally.

• Gray level in an image is viewed as random variables in the interval [0,1].One


fundamental descriptors of a random variable is probability function(PDF).

• PDF of transformed variable ,s is determined by gray level PDF of input image and by
the chosen transformation function.

Example

Before After Histogram Equalization


The quality is not improved much because the original image already has a broaden gray-
level scale.

HISTOGRAM MATCHING (SPECIFICATION)

• Histogram equalization has a disadvantage which is that it can generate only one type
of output image.

• With Histogram Specification, we can specify the shape of the histogram that we wish
the output image to have.

• It doesn’t have to be a uniform histogram

Consider the continuous domain

Let pr(r) denote continuous probability density function of gray-level of input image, r

Let pz(z) denote desired (specified) continuous probability density function of gray-level of
output image, z

Let s be a random variable with the property

r
s  T ( r )   pr ( w )dw
0
Where w is a dummy variable of integration.

Next, we define a random variable z with the property

z
g( z )  p
0
z ( t )dt  s

Where t is a dummy variable of integrationthus

s = T(r) = G(z)

Therefore, z must satisfy the condition

z = G-1(s) = G-1[T(r)]

Assume G-1 exists and satisfies the condition (a) and (b)

We can map an input gray level r to output gray level z

Procedure Conclusion

1. Obtain the transformation function T(r) by calculating the histogram equalization of


the input image
r
s=T (r )=∫ pr (w )dw
0

2. Obtain the transformation function G(z) by calculating histogram equalization of the


desired density function
z
G( z)=∫ p z (t )dt=s
0

3. Obtain the inversed transformation function G-1

z = G-1(s) = G-1[T(r)]

4. Obtain the output image by applying the processed gray-level from the inversed
transformation function to all the pixels in the input image

Example

Assume an image has a gray level probability density function pr(r) as shown
  2r  2 ;0  r  1
pr ( r )  
 0 ; elsewhere
r

0
pr ( w )dw  1

Discrete formulation
k
s k =T (r k )= ∑ pr (r j )
j=0
k
nj
¿∑ k=0,1,2,. .. , L−1
j =0 n

k
G( z k )=∑ p z ( z i )=sk k=0,1,2,. .. , L−1
i=0

z k =G−1 [ T (r k ) ]
¿ G−1 [ s k ] k =0,1,2, .. . , L−1

Example

Image of Mars moon


Image is dominated by large, dark areas, resulting in a histogram characterized by a large
concentration of pixels in pixels in the dark end of the gray scale

IMAGE EQUALIZATION

The histogram equalization doesn’t make the result image look better than the original image.
Consider the histogram of the result image, the net effect of this method is to map a very
narrow interval of dark pixels into the upper end of the gray scale of the output image. As a
consequence, the output image is light and has a washed-out appearance.

Transformation function for histogram equalization


Histogram of the result image

Result image after histogram equalization

Since the problem with the transformation function of the histogram equalization was caused
by a large concentration of pixels in the original image with levels near 0 a reasonable
approach is to modify the histogram of that image so that it does not have this property.
Histogram Specification

1) The transformation function G(z) obtained from


k
G( z k )=∑ p z ( z i )=sk
i=0
k =0,1,2,. .. , L−1

2) the inverse transformation G-1(s)


Result image and its histogram

• Histogram specification is a trial-and-error process

• There are no rules for specifying histograms, and one must resort to analysis on a
case-by-case basis for any given enhancement task.

LOCAL ENHANCEMENT

• Histogram processing methods are global processing, in the sense that pixels are
modified by a transformation function based on the gray-level content of an entire
image.
• Sometimes, we may need to enhance details over small areas in an image, which is
called a local enhancement.

(a)(b)(c)

a) Original image (slightly blurred to reduce noise)

(b) global histogram equalization (enhance noise & slightly increase contrast but the
construction is not changed)
(c) local histogram equalization using 7x7 neighborhood (reveals the small squares inside
larger ones of the original image.

• Define a square or rectangular neighborhood and move the center of this area from
pixel to pixel.

• At each location, the histogram of the points in the neighborhood is computed and
either histogram equalization or histogram specification transformation function is
obtained.

• Another approach used to reduce computation is to utilize nonoverlapping regions,


but it usually produces an undesirable checkerboard effect.

In the figure(c)basically, the original image consists of many small squares inside the
larger dark ones.However, the small squares were too close in gray level to the larger
ones, and their sizes were too small to influence global histogram equalization
significantly.So, when we use the local enhancement technique, it reveals the small
areas.Note also the finer noise texture is resulted by the local processing using
relatively small neighborhoods.
ARITHMETIC/LOGIC OPERATIONS

• Arithmetic/Logic operations perform on pixel by pixel basis between two or more


images

• except NOT operation which perform only on a single image

LOGIC OPERARIONS

• Logic operation performs on gray-level images, the pixel values are processed as
binary numbers

• light represents a binary 1, and dark represents a binary 0

• NOT operation = negative transformation

Example of AND Operation

Original image AND image mask result of AND operation


Example of OR Operation

Original image OR image mask result of OR operation

IMAGE SUBTRACTION

g(x,y) = f(x,y) – h(x,y)

• Enhancement of the differences between images

(a). original fractal image


b). result of setting the four lower-order bit planes to zero

– refer to the bit-plane slicing

– the higher planes contribute significant detail

– the lower planes contribute more to fine detail

– image( b). is nearly identical visually to image( a), with a very slightly drop in
overall contrast due to less variability of the gray-level values in the image.

c). difference between (a). and(b). (Nearly black)

d). histogram equalization of (c). (Perform contrast stretching transformation)


BASICS OF SPATIAL FILTERING

• use filter (can also be called as mask/kernel/template or window)

• the values in a filter subimage are referred to as coefficients, rather than pixel.

• our focus will be on masks of odd sizes, e.g. 3x3, 5x5,…


Spatial Filtering Process

Simply move the filter mask from point to point in an image.at each point (x,y),
the response of the filter at that point is calculated using a predefined relationship.

R=w1 z 1 +w2 z 2 +. ..+wmn z mn


mn
¿∑ w i zi
i=i

SMOOTHING SPATIAL FILTERS

• used for blurring and for noise reduction

• blurring is used in preprocessing steps, such as

– removal of small details from an image prior to object extraction

– bridging of small gaps in lines or curves


• noise reduction can be accomplished by blurring with a linear filter and also by a
nonlinear filter

SMOOTHING LINEAR FILTERS

Output is simply the average of the pixels contained in the neighborhood of the filter mask.It
is called averaging filters or lowpass filters.By replacing the value of every pixel in an image
by the average of the gray levels in the neighborhood will reduce the “sharp” transitions in
gray levels.For sharp transitions

• random noise in the image

• edges of objects in the image

Thus, smoothing can reduce noises (desirable) and blur edges (undesirable)

3x3 Smoothing Linear Filters

box filter weighted avera


the center is the most important
pixels are inversely weighted as a
their distance from the center of
Weighted average filter

The basic strategy behind weighting the center point the highest and then reducing the
value of the coefficients as a function of increasing distance from the origin is simply
an attempt to reduce blurring in the smoothing process.

Example

a). original image 500x500 pixel

b). - f). results of smoothing with square averaging filter masks of size n = 3, 5, 9, 15
and 35, respectively.

Note:

– big mask is used to eliminate small objects from an image.


– the size of the mask establishes the relative size of the objects that will be
blended with the background.

ORDER-STATISTICS FILTERS (NONLINEAR FILTERS)

• the response is based on ordering (ranking) the pixels contained in the image area
encompassed by the filter

• example

– median filter : R = median{zk|k = 1,2,…,n x n}

– max filter : R = max{zk|k = 1,2,…,n x n}

– min filter : R = min{zk|k = 1,2,…,n x n}

• note: n x n is the size of the mask

Median Filters

• replaces the value of a pixel by the median of the gray levels in the neighborhood of
that pixel (the original value of the pixel is included in the computation of the median)

• quite popular because for certain types of random noise (impulse noise [ salt and
pepper noise) , they provide excellent noise-reduction capabilities, with considering
less blurring than linear smoothing filters of similar size.
Example : Median Filters

Sharpening Spatial Filters

• to highlight fine detail in an image


• or to enhance detail that has been blurred, either in error or as a natural effect of a
particular method of image acquisition.

Blurring vs. Sharpening

• as we know that blurring can be done in spatial domain by pixel averaging in a


neighbors

• since averaging is analogous to integration

Thus, we can guess that the sharpening must be accomplished by spatial


differentiation.

Derivative operator

• the strength of the response of a derivative operator is proportional to the degree of


discontinuity of the image at the point at which the operator is applied.

• thus, image differentiation

– enhances edges and other discontinuities (noise)

– Deemphasizes area with slowly varying gray-level values.

First-order derivative

• a basic definition of the first-order derivative of a one-dimensional function f(x) is the


difference
∂f
Second-order derivative =f ( x +1)−f ( x )
∂x
• similarly, we define the second-order derivative of a one-dimensional function f(x) is
the difference

∂2 f
=f ( x+1 )+ f ( x−1 )−2 f (x )
∂ x2

Response of First and Second order derivatives

Response of first order derivative is:

• zero in flat segments (area of constant grey values)

• Non zero at the onset of a grey level step or ramp

• Non zero along ramps

Response of second order derivative is:


• Zero in flat areas

• Non zero at the onset of a grey level step or ramp

• Zero along ramps of constant slope

First and Second-order derivative of f(x,y)

• when we consider an image function of two variables, f(x,y), at which time we will
dealing with partial derivatives along the two spatial axes.

Gradient operator

f ( x, y ) f ( x, y ) f ( x, y )
f   
xy x y
Laplacian operator

 2
f ( x , y )  2
f ( x, y )
 f 
2

x 2
y 2
Discrete Form of Laplacian

from

2 f
 f ( x, y  1)  f ( x, y  1)  2 f ( x, y )
y 2

2 f
 f ( x, y  1)  f ( x, y  1)  2 f ( x, y )
y 2

yields

 2 f  [ f ( x  1, y )  f ( x  1, y )
 f ( x, y  1)  f ( x, y  1)  4 f ( x, y )]

Result Laplacian mask

Laplacian mask implemented an extension of diagonal neighbors


Other implementation of Laplacian masks

Give the same result, but we have to keep in mind that when combining (add / subtract) a
Laplacian-filtered image with another image.

Effect of Laplacian Operator

• as it is a derivative operator,

– it highlights gray-level discontinuities in an image

– it deemphasizes regions with slowly varying gray levels

• tends to produce images that have

– grayish edge lines and other discontinuities, all superimposed on a dark,


featureless background

Correct the effect of featureless background

• easily by adding the original and Laplacian image.


• be careful with the Laplacian filter used

 f ( x, y )   2 f ( x, y )
g ( x, y )  
 f ( x, y )   f ( x , y )
2

Example

a). image of the North pole of the moon

b). Laplacian-filtered image with

1 1 1

1 -8 1

1 1 1

c). Laplacian image scaled for display purposes

d). image enhanced by addition with original image

Mask of Laplacian + addition

To simplify the computation, we can create masks which do both operations,


Laplacian Filter and Addition of the original image

g( x , y )=f (x , y )−[ f ( x +1, y )+f (x −1, y )


+f ( x , y +1 )+f ( x , y −1)+4 f ( x , y )]
=5 f ( x , y )−[ f ( x +1, y )+f ( x−1, y )
+f ( x , y +1 )+f ( x , y −1)]
UNIT-4

IMAGE ENHANCEMENT IN FREQUENCY DOMAIN

BACKGROUND

• Any function that periodically repeats itself can be expressed as the sum of sines
and/or cosines of different frequencies, each multiplied by a different coefficient
(Fourier series).

• Even functions that are not periodic (but whose area under the curve is finite) can be
expressed as the integral of sines and/or cosines multiplied by a weighting function
(Fourier transform).

• The advent of digital computation and the “discovery” of fast Fourier Transform
(FFT) algorithm in the late 1950s revolutionized the field of signal processing, and
allowed for the first time practical processing and meaningful interpretation of a host
of signals of exceptional human and industrial importance.

• The frequency domain refers to the plane of the two dimensional discrete Fourier
transform of an image.
• The purpose of the Fourier transform is to represent a signal as a linear combination
of sinusoidal signals of various frequencies.

Introduction to the Fourier Transform and the Frequency Domain

The one-dimensional Fourier transform and its inverseFourier transform (continuous case)

F (u )   f ( x)e  j 2ux dx where j   1



Inverse Fourier transform e =cosθ + j sin θ

∞ j2π ux
f (x )=∫−∞ F(u)e du

The two-dimensional Fourier transform and its inverseFourier transform (continuous case)
∞ ∞
∫ ∫
F(u, v)= −∞ −∞ f (x, y)e
−j2π(ux+vy)
dx dy
Inverse Fourier transform
∞ ∞ j 2π(ux+vy)
f (x , y)=∫−∞ ∫−∞ F(u,v)e dudv
The one-dimensional Fourier transform and its inverse (discrete time case)

Fourier transform (DFT)


M −1
1
F(u )=
M
∑ f (x )e− j2 π ux/ M for u=0,1,2, .. . , M −1
x=0

Inverse Fourier transform (IDFT)


M −1
f (x )= ∑ F (u )e j 2π ux/M for x=0,1,2, .. . , M −1
u=0

The 1/M multiplier in front of the Fourier transform sometimes is placed in the front of
the inverse instead. Other times both equations are multiplied by 1/ M

• Unlike continuous case, the discrete Fourier transform and its inverse always exist,
only if f(x) is finite duration. F(u) can be expressed in polar coordinates:

F (u )  F (u ) e jf (u )
1/2
where F (u )  �� R 2 (u )  I 2 (u ) �
� (magnitude or spectrum)
�I (u ) �
f (u )  tan 1 � � (phase angle or phase spectrum)
�R (u ) �

– R(u): the real part of F(u)

– I(u): the imaginary part of F(u)

Power spectrum:
2 2 2
P(u)=|F (u)| =R (u)+I (u)
Some One-Dimensional Fourier Transform Examples
The transform of a constant function is a DC value only

The transform of a delta function is a constant

BASIC FILTERING IN THE FREQUENCY DOMAIN

Frequency is directly related to rate of change. The frequency of fast varying components in
an image is higher than slowly varying components
BASIC FILTERS AND THEIR PROPERTIES

Multiply all values of F(u,v) by the filter function (notch filter):

H (u , v )= {
1
0 if (u , v )=( M /2, N /2)
otherwise .
All this filter would do is set F(0,0) to zero (force the average value of an image to zero) and
leave all other frequency components of the Fourier transform untouched and make
prominent edges stand out

Low frequency filters: eliminate the gray-level detail and keep the general gray-level
appearance. (blurring the image)

Low frequency filters: have less gray-level variations in smooth areas and emphasized
transitional (e.g., edge and noise) gray-level detail. (sharpening images)
The distinction and links between spatial and frequency filtering

 If the size of spatial and frequency filters is same, then the computation burden in
spatial domain is larger than in frequency domain;

 However, whenever possible, it makes more sense to filter in the spatial domain using
small filter masks.

 Filtering in frequency is more intuitive. We can specify filters in the frequency, take
their inverse transform, and the use the resulting filter in spatial domain as a guide for
constructing smaller spatial filter masks.

Fourier transform and its inverse are linear process, so the following discussion is limited to
linear processes

There is two reasons that filters based on Gaussian functions are of particular importance: 1)
their shapes are easily specified; 2) both the forward and inverse Fourier transforms of a
Gaussian are real Gaussian function

• Let H(u) denote a frequency domain, Gaussian filter function given the equation
2 2
H (u)=Ae−u / 2 σ

where the standard deviation of the Gaussian curve.

• The corresponding filter in the spatial domain is


Smoothing Frequency-Domain Filters

• The basic model for filtering in the frequency domain

G(u , v)=H (u, v) F(u, v )


where F(u,v): the Fourier transform of the image to be smoothed

H(u,v): a filter transfer function

• Smoothing is fundamentally a lowpass operation in the frequency domain.

• There are several standard forms of lowpass filters (LPF).

– Ideal lowpass filter

– Butterworth lowpass filter

– Gaussian lowpass filter

IDEAL LOWPASS FILTERS (ILPFS)

The simplest lowpass filter is a filter that “cuts off” all high-frequency components of the
Fourier transform that are at a distance greater than a specified distance D0 from the origin of
the transform
• The transfer function of an ideal lowpass filter

H (u , v )=
{
1
0
if D(u , v )≤D 0
if D (u , v )>D 0

where D(u,v) : the distance from point (u,v) to the center of ther frequency rectangle (M/2,
N/2)
1
2
D ( u , v )=[( u−M / 2)2 +( v−N /2 )2 ]

ILPF is a type of “nonphysical” filters and can’t be realized with electronic components and
is not very practical.
The blurring and ringing phenomena can be seen, in which ringing behavior is characteristic
of ideal filter.

Another example of ILPF

Figure 4.13 (a) A frequency-domain ILPF of radius 5. (b) Corresponding spatial filter. (c)
Five impulses in the spatial domain, simulating the valuesof five pixels. (d) Convolution of
(b) and (c) in the spatial domain.

f (x , y )∗h( x , y )⇔ F (u ,v ) H (u ,v )

Notation: the radius of center component and the number of circles per unit distance from the
origin are inversely proportional to the value of the cutoff frequency.
frequency

spatial

spatial

spatial

BUTTERWORTH LOWPASS FILTERS (BLPFS)

The BLPF may be viewed as a transition between ILPF AND GLPF, BLPF of order 2 is a
good compromise between effective lowpass filtering and acceptable ringing characteristics.

1
H (u , v )= 2n
1+ [ D(u , v )/ D0 ]
n=2 ,D0=5,15,30,80,and 230

Butterworth Lowpass Filters (BLPFs)(Spatial Representation)


Gaussian Lowpass Filters (GLPFs)

−D2 (u , v ) /2 D 20
H (u , v )=e
D0=5,15,30,80,and 230

Gaussian lowpass filter for reducing the horizontal sensor scan lines and simplifying the
detection of features like the interface boundaries.

SHARPENING FREQUENCY DOMAIN FILTER


H hp (u, v)  1  H lp (u, v)

Ideal highpass filter

H (u , v )=
{0
1
if D(u , v )≤D 0
if D (u , v )> D0

Butterworth highpass filter

1
H (u , v )= 2n
1+ [ D 0 / D(u , v ) ]

Gaussian highpass filter

−D 2 ( u, v )/2 D 20
H (u , v )=1−e

IDEAL HIGHPASS FILTERS (IHPFS)


Non-physically realizable with electronic component and have the same ringing properties as
ILPFs.

H (u , v )=
{
0
1
if D(u , v )≤D 0
if D (u , v )> D0

Highpass Filters Spatial Representations


BUTTERWORTH HIGHPASS FILTERS

The result is smoother than that of IHPFs and sharper than that of GHPFs

1
H (u , v )= 2n
1+ [ D 0 / D(u , v ) ]

GAUSSIAN HIGHPASS FILTERS


The result is the smoothest in three types of high-pass filters

−D 2 ( u, v )/2 D 20
H (u , v )=1−e

The plot of Laplacian in frequency and spatial domain


Frequency
domain

Spatial domain

HOMOMORPHIC FILTERING

Problems:

When the illumination radiating to an object is non-uniform, the detail of the dark part in the
image is more discernable.

aims:

Simultaneously compress the gray-level range and enhance contrast, eliminate the effect of
non-uniform illumination, and emphasis the details.

Principal:

Generally, the illumination component of an image is characterized by slow spatial variations,


while the reflectance components tends to vary abruptly, particularly at the junctions of
dissimilar objects. These characteristics lead to associating the low frequencies of the Fourier
transform of the logarithm of an image with illumination and the high frequencies with
reflectance.

Two examples
PART B

UNIT -5

IMAGE RESTORATION

Image Restoration refers to a class of methods that aim to remove or reduce the degradations
that have occurred while the digital image was being obtained. All natural images when
displayed have gone through some sort of degradation:
 During Display Mode

 During Acquisition Mode, Or

 During processing mode

The degradations may be due to


 Sensor Noise

 Blur Due To Camera Misfocus

 Relative Object-Camera Motion

 Random Atmospheric Turbulence

 Others

In most of the existing image restoration methods we assume that the degradation process can
be described using a mathematical model.

IMAGE DEGRADATION AND RESTORATION MODELS


Typical Types of Degradation: Motion Blur

How does motion blur occur ?

• A camera works by exposing a sheet of light sensitive film to a scene, for a short
period of time.

• The light from the scene, hitting the film, causes the film to change chemically, and
eventually results in a picture representation of the scene.
• This is known as an exposure.

• If the scene changes during that exposure, a blurred image will result, since light from
many scenes hit the film.
NOISE MODELS

The principal sources of noise in digital images arise during image acquisition (digitization)
and/or transmission.The performance of imaging sensors is affected by a variety of factors,
such as environmental conditions during image acquisition.
RESTORATION USING SPATIAL FILTERING

Spatial filtering is the method of choice in situations when only additive noise is present.

MEAN FILTERS

(1) Arithmetic mean filters


 Simplest of the mean filters
 Operation can be implemented using a convolution mask in which all coefficients
have value 1/mn.
 Noise is reduced as a result of blurring.

GEOMETRIC MEAN FILTER

Here each restored pixel is given by the product of the pixels in the sub image window
raised to the power of 1/mn.

HARMONIC MEAN FILTER

It works well for salt noise, but fails for pepper noise and it does well with other types of
noise like Gaussian noise.
MEDIAN FILTER

This filter replaces the value of a pixel by the median of the gray levels in the neighborhood
of that pixel.The original value of the pixel is included in the computation of the
median.Median filters provide excellent noise reduction capabilities,with less blurring.
Median filters are effective in the presence of both bipolar and unipolar impulse noise.

Max and min filters

You might also like