Dip Unit 3

Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

UNIT-III

IMAGE ENHANCEMENT
IMAGE ENHANCEMENT IN SPATIAL DOMAIN:
3.1. Introduction
The principal objective of enhancement is to process an image so that the result is more
suitable than the original image for a specific application. Image enhancement approaches
fall into two board categories.
1. Spatial domain methods
2. Frequency domain methods
The term spatial domain refers to the image plane itself and approaches in this categories are
based on direct manipulation of pixel in an image. Spatial domain process are denoted by the
expression
g(x,y)=T[f(x,y)]
Where f(x,y)- input image, T- operator on f, defined over some neighborhood of f(x,y)
and g(x,y)-processed image
The neighborhood of a point (x,y) can be explain by using as square or rectangular sub image
area centered at (x,y).

The center of sub image is moved from pixel to pixel starting at the top left corner. The
operator T is applied to each location (x,y) to find the output g at that location . The process
utilizes only the pixel in the area of the image spanned by the neighborhood.
3.2 Basic Gray Level Transformation Functions
It is the simplest form of the transformations when the neighborhood is of size IXI. In this
case g depends only on the value of f at (x,y) and T becomes a gray level transformation
function of the forms
S=T(r)
r- Denotes the gray level of f(x,y)
s- Denotes the gray level of g(x,y) at any point (x,y)
Because enhancement at any point in an image deepens only on the gray level at that point,
technique in this category are referred to as point processing.
There are basically three kinds of functions in gray level transformation –
3.2.1 Point Processing:
(i) Contract stretching:
It produces an image of higher contrast than the original one. The operation is performed by
darkening the levels below m and brightening the levels above m in the original image.

In this technique the value of r below m are compressed by the transformation function into a
narrow range of s towards black .The opposite effect takes place for the values of r above m.
(ii) Thresholding function:
It is a limiting case where T(r) produces a two levels binary image. The values below m are
transformed as black and above m are transformed as white.

3.2.2 Basic Gray Level Transformation:


These are the simplest image enhancement techniques.
(i) Image Negative:
The negative of in image with gray level in the range [0, l, -1] is obtained by using the
negative transformation. The expression of the transformation is
s= L-1-r
Reverting the intensity levels of an image in this manner produces the equivalent of a
photographic negative. This type of processing is practically suited for enhancing white or
gray details embedded in dark regions of an image especially when the black areas are
dominant in size.
(ii) Log transformations:
The general form of the log transformation is s= c log(1+r)
Where c- constant and r ≥ o
This transformation maps a narrow range of gray level values in the input image into a wider
range of output gray levels. The opposite is true for higher values of input levels. We would
use this transformations to expand the values of dark pixels in an image while compressing
the higher level values. The opposite is true for inverse log transformation. The log
transformation function has an important characteristic that it compresses the dynamic range
of images with large variations in pixel values.
Eg- Fourier spectrum

(iii) Power Law Transformation:


Power law transformations has the basic form

Where c and y are positive constants.


Power law curves with fractional values of y 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 gray
levels. We may get various curves by varying values of y.
A variety of devices used for image capture, printing and display respond according to a
power law. The process used to correct this power law response phenomenon is called
gamma correction. For eg-CRT devices have intensity to voltage response that is a power
function. Gamma correction is important if displaying an image accurately on a computer
screen is of concern. Images that are not corrected properly can look either bleached out or
too dark. Color phenomenon also uses this concept of gamma correction. It is becoming more
popular due to use of images over the internet. It is important in general purpose contract
manipulation. To make an image black we use y>1 and y<1 for white image.
3.2.3 Piece wise linear transformation functions:
The principal advantage of piecewise linear functions is that these functions can be arbitrarily
Complex. But their specification requires considerably more user input.
(i) Contrast Stretching:
It is the simplest piecewise linear transformation function. We may have various low contrast
images and that might result due to various reasons such as lack of illumination, problem in
imaging sensor or wrong setting of lens aperture during image acquisition. The idea behind
contrast stretching is to increase the dynamic range of gray levels in the image Being
processed.
The location of points (r1,s1) and (r2,s2) control the shape of the curve
a) If r1=r2 and s1=s2, the transformation is a linear function that deduces no change in gray
levels.
b) If r1=s1, s1=0 , and s2=L-1, then the transformation become a thresholding function that
creates a binary image
c) Intermediate values of (r1, s1) and (r2, s2) produce various degrees of spread in the gray
value of the output image thus effecting its contract.
Generally r1≤ r2 and s1≤ s2 so that the function is single valued and monotonically
increasing.
(ii) Gray Level Slicing:

Highlighting a specific range of gray levels in an image is often desirable. For


example when enhancing features such as masses of water in satellite image and enhancing
flaws in x- ray images.
There are two ways of doing this-
(1) One method is to display a high value for all gray level in the range. Of interest and a low
value for all other gray level.

(2) Second method is to brighten the desired ranges of gray levels but preserve the
background and gray level tonalities in the image.
(iii) Bit Plane Slicing:
Sometimes it is important to highlight the contribution made to the total image
appearance by specific bits. Suppose that each pixel is represented by 8 bits. Imagine that an
image is composed of eight 1-bit planes ranging from bit plane 0 for the least significant bit
to bit plane 7 for the most significant bit. In terms of 8-bit bytes, plane 0 contains all the
lowest order bits in the image and plane 7 contains all the high order bits.
High order bits contain the majority of visually significant data and contribute to more subtle
details in the image. Separating a digital image into its bits planes is useful for analyzing the
relative importance played by each bit of the image. It helps in determining the adequacy of
the number of bits used to quantize each pixel. It is also useful for image compression.
3.3 Histogram Processing:
The histogram of a digital image with gray levels in the range [0, L-1] is a discrete function
of the form
H(rk)=nk
where rk is the kth gray level and nk is the number of pixels in the image having the level rk..
A normalized histogram is given by the equation
p(rk)=nk/n for k=0,1,2,…..,L-1
P(rk) gives the estimate of the probability of occurrence of gray level rk.
The sum of all components of a normalized histogram is equal to 1.
The histogram plots are simple plots of H(rk)=nk versus rk.

In the dark image the components of the histogram are concentrated on the low (dark) side of the
gray scale. In case of bright image the histogram components are baised towards the high side of
the gray scale. The histogram of a low contrast image will be narrow and will be centered
towards the middle of the gray scale.
The components of the histogram in the high contrast image cover a broad range of the gray
scale. The net effect of this will be an image that shows a great deal of gray levels details and has
high dynamic range.
3.3.1 Histogram Equalization:
Histogram equalization is a common technique for enhancing the appearance of images. Suppose
we have an image which is predominantly dark. Then its histogram would be skewed towards the
lower end of the grey scale and all the image detail are compressed into the dark end of the
histogram. If we could „stretch out‟ the grey levels at the dark end to produce a more uniformly
distributed histogram then the image would become much clearer.
Let there be a continuous function with r being gray levels of the image to be e nhanced. The
range of r is [0, 1] with r=0 repressing black and r=1 representing white. The transformation
function is of the form
S=T(r) where 0<r<1
It produces a level s for every pixel value r in the original image. The transformation function
is assumed to fulfill two condition T(r) is single valued and monotonically increasing in the
internal 0<T(r)<1 for 0<r<1.The transformation function should be single valued so that the
inverse transformations should exist. Monotonically increasing condition preserves the
increasing order from black to white in the output image. The second conditions guarantee
that the output gray levels will be in the same range as the input levels. The gray levels of the
image may be viewed as random variables in the interval [0.1]. The most fundamental
descriptor of a random variable is its probability density function (PDF) Pr(r) and Ps(s)
denote the probability density functions of random variables r and s respectively. Basic
results from an elementary probability theory states that if Pr(r) and Tr are known and T-1(s)
satisfies conditions (a), then the probability density function Ps(s) of the transformed variable
is given by the formula

Thus the PDF of the transformed variable s is the determined by the gray levels PDF of the
input image and by the chosen transformations function.
A transformation function of a particular importance in image processing

This is the cumulative distribution function of r.


Using this definition of T we see that the derivative of s with respect to r is

Substituting it back in the expression for Ps we may get

An important point here is that Tr depends on Pr(r) but the resulting Ps(s) always is uniform,
and independent of the form of P(r). For discrete values we deal with probability and
summations instead of probability density functions and integrals. The probability of
occurrence of gray levels rk in an image as approximated

N is the total number of the pixels in an image.


nk is the number of the pixels that have gray level rk.
L is the total number of possible gray levels in the image.
The discrete transformation function is given by

Thus a processed image is obtained by mapping each pixel with levels rk in the input image
into a corresponding pixel with level sk in the output image. A plot of Pr (rk) versus rk is
called a histogram. The transformation function given by the above equation is the called
histogram equalization or linearization. Given an image the process of histogram equalization
consists simple of implementing the transformation function which is based information that
can be extracted directly from the given image, without the need for further parameter
specification.

Equalization automatically determines a transformation function that seeks to produce an


output image that has a uniform histogram. It is a good approach when automatic
enhancement is needed.
3.3.2 Histogram Matching (Specification):
In some cases it may be desirable to specify the shape of the histogram that we wish the
processed image to have. Histogram equalization does not allow interactive image
enhancement and generates only one result: an approximation to a uniform histogram.
Sometimes we need to be able to specify particular histogram shapes capable of highlighting
certain gray-level ranges. The method use to generate a processed image that has a specified
histogram is called histogram matching or histogram specification.
Algorithm:
1. Compute sk=Pf (k), k = 0, …, L-1, the cumulative normalized histogram of f .
2. Compute G(k), k = 0, …, L-1, the transformation function, from the given histogram hz 3.
Compute G-1(sk) for each k = 0, …, L-1 using an iterative method (iterate on z), or in effect,
directly compute G-1(Pf (k))
4. Transform f using G-1(Pf (k)) .
3.4 Basic filtering through the enhancement:
Spatial filtering is an example of neighborhood operations, in this the operations are done on
the values of the image pixels in the neighborhood and the corresponding value of a sub
image that has the same dimensions as of the neighborhood This sub image is called a filter,
mask, kernel, template or window; the values in the filter sub image are referred to as
coefficients rather than pixel. Spatial filtering operations are performed directly on the pixel
values (amplitude/gray scale) of the image The process consists of moving the filter mask
from point to point in the image. At each point (x,y) the response is calculated using a
predefined relationship.

For linaer spatial filtering the response is given by a sum of products of the filter coefficient
and the corresponding image pixels in the area spanned by the filter mask. The results R of
liner filtering with the filter mask at point (x,y) in the image is

The sum of products of the mask coefficient with the corresponding pixel directly under the
mask. The coefficient w (0,0) coincides with image value f(x,y) indicating that mask it
centered at (x,y) when the computation of sum of products takes place. For a mask of size
MxN we assume m=2a+1 and n=2b+1, where a and b are nonnegative integers. It shows that
all the masks are of add size. In the general liner filtering of an image of size f of size M*N
with a filter mask of size m*m is given by the expression

Where a= (m-1)/2 and b = (n-1)/2


To generate a complete filtered image this equation must be applied for x=0, 1, 2, -----M-1
and y=0,1,2---,N-1. Thus the mask processes all the pixels in the image. The process of linear
filtering is similar to frequency domain concept called convolution. For this reason, linear
spatial filtering often is referred to as convolving a mask with an image. Filter mask are
sometimes called convolution mask.
R= W,Z,+W2, Z2 +….+ Wmn Zmn
Where w‟s are mask coefficients and z‟s are the values of the image gray levels
corresponding to those coefficients, mn is the total number of coefficients in the mask.
An important point in implementing neighborhood operations for spatial filtering is the issue
of what happens when the center of the filter approaches the border of the image. There are
several ways to handle this situation.
i) To limit the excursion of the center of the mask to be at distance of less than (n-1) /2 pixels
form the border. The resulting filtered image will be smaller than the original but all the
pixels will be processed with the full mask.
ii) Filter all pixels only with the section of the mask that is fully contained in the image. It
will create bands of pixels near the border that will be processed with a partial mask.
iii) Padding the image by adding rows and columns of o‟s & or padding by replicating rows
and columns. The padding is removed at the end of the process.
IMAGE ENHANCEMENT IN FREQUENCY DOMAIN:
3.5 Basics of filtering in frequency domain:
Basic steps of filtering in frequency Domain
i) Multiply the input image by (-1) X+Y to centre the transform
ii) Compute F(u,v), Fourier Transform of the image
iii) Multiply f(u,v) by a filter function H(u,v)
iv) Compute the inverse DFT of Result of (iii)
v) Obtain the real part of result of (iv)
vi) Multiply the result in (v) by (-1)x=y
H(u,v) called a filter because it suppresses certain frequencies from the image while leaving
others unchanged.
3.6 Image smoothing:
Edges and other sharp transition of the gray levels of an image contribute significantly to the
high frequency contents of its Fourier transformation. Hence smoothing is achieved in the
frequency domain by attenuation a specified range of high frequency components in the
transform of a given image. Basic model of filtering in the frequency domain is
G(u,v) = H(u,v)F(u,v)
F(u,v) - Fourier transform of the image to be smoothed objective is to find out a filter
function H (u,v) that yields G (u,v) by attenuating the high frequency component of F (u,v)
There are three types of low pass filters
1. Ideal
2. Butterworth
3. Gaussian
(i) Ideal Low pass filter:
It is the simplest of all the three filters. It cuts of all high frequency component of the Fourier
transform that are at a distance greater that a specified distance D0 form the origin of the
transform. it is called a two – dimensional ideal low pass filter (ILPF) and has the transfer
function
Where D0 is a specified nonnegative quantity and D(u,v) is the distance from point (u,v) to
the center of frequency rectangle. If the size of image is M*N , filter will also be of the same
size so center of the frequency rectangle (u,v) = (M/2, N/2) because of center transform

Because it is ideal case. So all frequency inside the circle are passed without any attenuation
where as all frequency outside the circle are completely attenuated. For an ideal low pass
filter cross section, the point of transition between H (u,v) =1 and H(u,v)=0 is called of the “
cut of frequency”.

(ii) Butterworth Low pass filter:


It has a parameter called the filter order. For high values of filter order it approaches the form
of the ideal filter whereas for low filter order values it reach Gaussian filter. It may be viewed
as a transition between two extremes. The transfer function of a Butterworth low pass filter
(BLPF) of order n with cut off frequency at distance Do from the origin is defined as

Most appropriate value of n is 2.It does not have sharp discontinuity unlike ILPF that
establishes a clear cutoff between passed and filtered frequencies. Defining a cutoff
frequency is a main concern in these filters. This filter gives a smooth transition in blurring as
a function of increasing cutoff frequency. A Butterworth filter of order 1 has no ringing.
Ringing increases as a function of filter order. (Higher order leads to negative values).
(iii) Gaussian Low pass filter:
The transfer function of a Gaussian low pass filter is

Where D(u,v)- the distance of point (u,v) from the center of the transform
σ = D0- specified cut off frequency
The filter has an important characteristic that the inverse of it is also Gaussain.

3.7 Image Sharpening:


Image sharpening can be achieved by a high pass filtering process, which attenuates the low
frequency components without disturbing high-frequency information. These are radially
symmetric and completely specified by a cross section. If we have the transfer function of a
low pass filter the corresponding high pass filter can be obtained using the equation
Hhp (u,v)=1- Hlp (u,v)
(i) Ideal High pass filter:
This filter is opposite of the Ideal Low Pass filter and has the transfer function of the form

(ii) Butterworth High pass filter:


The transfer function of Butterworth High Pass filter of order n is given by the equation

(iii) Guassian High pass filter:


The transfer function of a Gaussain High Pass Filter is given by the equation

3.8 Homomorphic filtering:


Homomorphic filters are widely used in image processing for compensating the effect of no
uniform illumination in an image. Pixel intensities in an image represent the light reflected
from the corresponding points in the objects. As per as image model, image f(z,y) may be
characterized by two components: (1) the amount of source light incident on the scene being
viewed, and (2) the amount of light reflected by the objects in the scene. These portions of
light are called the illumination and reflectance components, and are denoted i ( x , y) and r (
x , y) respectively. The functions i ( x , y) and r ( x , y) combine multiplicatively to give the
image function f ( x , y):
f ( x , y) = i ( x , y).r(x, y) ----------(1)
where 0 < i ( x , y ) < a and 0 < r( x , y ) < 1. Homomorphic filters are used in such situations
where the image is subjected to the multiplicative interference or noise as depicted in
equation 1. We cannot easily use the above product to operate separately on the frequency
components of illumination and reflection because the Fourier transform of f ( x , y) is not
separable; that is
F[f(x,y)) not equal to F[i(x, y)].F[r(x, y)].
We can separate the two components by taking the logarithm of the two sides
ln f(x,y) = ln i(x, y) + ln r(x, y).
Taking Fourier transforms on both sides we get,
F[ln f(x,y)} = F[ln i(x, y)} + F[ln r(x, y)].
that is, F(x,y) = I(x,y) + R(x,y),
where F, I and R are the Fourier transforms ln f(x,y),ln i(x, y) ,
and ln r(x, y). respectively. The function F represents the Fourier transform of the sum of two
images: a low-frequency illumination image and a high-frequency reflectance image. If we
now apply a filter with a transfer function that suppresses low- frequency components and
enhances high-frequency components, then we can suppress the illumination component and
enhance the reflectance component. Taking the inverse transform of F ( x , y) and then anti-
logarithm, we get
f’ ( x , y) = i’ ( x , y) + r’(x, y)

3.9 Color Image enhancement:


Color of an object is determined by the nature of the light reflected from it. When a beam
of sunlight passes through a glass prism, the emerging beam of light is not white but consists
instead of a continuous spectrum of colors ranging from violet at one end to red at the other.
As shown in figure, the color spectrum may be divided into six broad regions: violet, blue,
green,yellow, orange, and red. When viewed in full color no color in the spectrum ends
abruptly, but rather each color blends smoothly into the next.

Fig: Color spectrum seen by passing white light through a prism.


Fig: Wavelength comprising the visible range of electromagnetic spectrum

As illustrated in Figure, visible light is composed of a relatively narrow band of frequencies


in the electromagnetic spectrum. A body that reflects light that is balanced in all visible
wavelengths appears white to the observer. However, a body that favors reflectance in a
limited range of the visible spectrum exhibits some shades of color. For example, green
objects reflect light with wavelengths primarily in the 500 to 570 nm range while absorbing
most of the energy at other wavelengths. Characterization of light is central to the science of
color. If the light is achromatic (void of color), its only attribute is its intensity, or amount.
Achromatic light is what viewers see on a black and white television set. Three basic
quantities are used to describe the quality of a chromatic light source: radiance, luminance,
andbrightness.
Radiance:
Radiance is the total amount of energy that flows from the light source, and it is usually
measuredinwatts(W).
Luminance:
Luminance, measured in lumens (lm), gives a measure of the amount of energy an observer
perceives from a light source. For example, light emitted from a source operating in the
far infrared region of the spectrum could have significant energy (radiance), but an observer
would hardly perceive it; its luminance would be almost zero.
Brightness:
Brightness is a subjective descriptor that is practically impossible to measure. It embodies
the achromatic notion of intensity and is one of the key factors in describing color sensation.
Cones are the sensors in the eye responsible for color vision. Detailed experimental
evidence has established that the 6 to 7 million cones in the human eye can be divided into
three principal sensing categories, corresponding roughly to red, green, and blue.
Approximately65% of all cones are sensitive to red light, 33% are sensitive to green light,
and only about 2% are sensitive to blue (but the blue cones are the most sensitive).
Fig: Absorption of light by RGB cones in human eye
Figure shows average experimental curves detailing the absorption of light by the red, green,
and blue cones in the eye. Due to these absorption characteristics of the human eye, colors arc
seen as variable combinations of the so- called primary colors red (R), green (G), and blue
(B).The primary colors can be added to produce the secondary colors of light --magenta (red
plus blue), cyan (green plus blue), and yellow (red plus green). Mixing the three primaries, or
a secondary with its opposite primary color, in the right intensities produces white light.
The characteristics generally used to distinguish one color from another are brightness,
hue, and saturation. Brightness embodies the chromatic notion of intensity. Hue is an attribute
associated with the dominant wavelength in a mixture of light waves. Hue represents
dominant color as perceived by an observer. Saturation refers to the relative purity or the
amount of white light mixed with a hue. The pure spectrum colors are fully saturated. Colors
such as pink(red and white) and lavender (violet and white) are less saturated, with the degree
of saturation being inversely proportional to the amount of white light-added.
Hue and saturation taken together are called chromaticity, and. therefore, a color may be
characterized by its brightness and chromaticity.

You might also like