You are on page 1of 18

UNIT-2

Image enhancement
Image enhancement is the mechanism to process the input image to make it more
appropriate and clearly visible for the required application. Image enhancement
improves the information content of the image and alters the visual impact of the
image on the observer. The objective of image enhancement is to modify
attributes of an image to make it more suitable for to achieve desired
enhancement. The choice of attributes and the way they will be modified are
specific to a given task.
Image enhancement simply means, transforming an image f into image g using
T. (Where T is the transformation. The values of pixels in images f and g are
denoted by r and s, respectively. As said, the pixel values r and s are related by
the expression,
s = T(r)
Where T is a transformation that maps a pixel value r into a pixel value s.

Image enhancement techniques can be divided into two broad categories:


1. Spatial domain techniques
2. Frequency domain techniques
In spatial domain techniques, we directly deal with the image pixels. The pixel
values are manipulated to achieve desired enhancement.
The operation can be formulated as g(x,y) = T[f(x,y)], where g is the output, f is
the input image and T is an operation on f defined over some neighbourhood of
(x,y).
Spatial domain: g(x,y)=f(x,y)*h(x,y)
In frequency domain methods, the image is first transferred in to frequency
domain. It means that, the Fourier Transform of the image is computed first. All
the enhancement operations are performed on the Fourier transform of the image
and then the Inverse Fourier transform is performed to get the resultant image.
Frequency domain: G(w1,w 2)=F(w1,w 2)H(w1,w 2)

Gray Level Transformation


All Image Processing Techniques focused on gray level transformation as it
operates directly on pixels. The gray level image involves 256 levels of gray and
in a histogram, horizontal axis spans from 0 to 255, and the vertical axis depends
on the number of pixels in the image.

There are three basic grey level transformation.

 Linear
 Logarithmic
 Power – law
 Piecewise Linear Transformation function
The overall graph of these transitions has been shown below.

Linear transformation
First we will look at the linear transformation. Linear transformation includes
simple identity and negative transformation.
Identity transition is shown by a straight line. In this transition, each value of the
input image is directly mapped to each other value of output image. That results
in the same input image and output image. And hence is called identity
transformation. It has been shown below:
Negative transformation
The second linear transformation is negative transformation, which is invert of
identity transformation. In negative transformation, each value of the input
image is subtracted from the L-1 and mapped onto the output image.

Input Image

Output Image

In this case the following transition has been done.


s = (L – 1) – r
since the input image of Einstein is an 8 bpp image, so the number of levels in
this image are 256. Putting 256 in the equation, we get this
s = 255 – r
So each value is subtracted by 255 and the result image has been shown above.
So what happens is that, the lighter pixels become dark and the darker picture
becomes light. And it results in image negative.
It has been shown in the graph below.

Logarithmic transformations
Logarithmic transformation further contains two type of transformation. Log
transformation and inverse log transformation.

Log transformation
The log transformations can be defined by this formula
s = c log(r + 1).
Where s and r are the pixel values of the output and the input image and c is a
constant. The value 1 is added to each of the pixel value of the input image
because if there is a pixel intensity of 0 in the image, then log (0) is equal to
infinity. So 1 is added, to make the minimum value at least 1.
During log transformation, the dark pixels in an image are expanded as compare
to the higher pixel values. The higher pixel values are kind of compressed in log
transformation. This result in following image enhancement.
Input Image

Log Tranform Image

The inverse log transform is opposite to log transform.

Power – Law transformations


There are further two transformation is power law transformations, that include
nth power and nth root transformation. These transformations can be given by
the expression:
s=cr^γ
This symbol γ is called gamma, due to which this transformation is also known
as gamma transformation.
Variation in the value of γ varies the enhancement of the images. Different
display devices / monitors have their own gamma correction, that’s why they
display their image at different intensity.
This type of transformation is used for enhancing images for different type of
display devices. The gamma of different display devices is different. For
example Gamma of CRT lies in between of 1.8 to 2.5, that means the image
displayed on CRT is dark.

Correcting gamma.
s=cr^γ
s=cr^(1/2.5)
The same image but with different gamma values has been shown here.

For example
Gamma = 10
Gamma = 8

Gamma = 6

PIECEWISE LINEAR TRANSFORMATION METHOD

In piecewise linear transform every pixel of the image will be manipulated. This
transformation technique aims to improve quality of the image by changing the
range of pixels intensity values in the original image. A common advantage of
this technique is that changing complex functions can be solved using the
piecewise linear method.
There are three types of transformation:
1.Contrast stretching method
2.Intensity level slicing method
3.Bit plane slicing method

A. Contrast Stretching Method


Contrast stretching (often called normalization) is a simple image enhancement
technique that attempts to improve the contrast in an image by `stretching' the
range of intensity values it contains to span a desired range of values.
Contrast is the difference between maximum and minimum pixel intensity.
Contrast = 225.

 The figure is the typical transformation used for contrast stretching. The
locations of points (r1, s1) and (r2, s2) control the shape of the
transformation function.
 If r1 = s1 and r2 = s2, the transformation is a linear function that produces
no changes in gray levels.
 If r1 = r2, s1 = 0 and s2 = L-1, the transformation becomes a thresholding
function that creates a binary image.
 Intermediate values of (r1, s1) and (r2, s2) produce various degrees of
spread in the gray levels of the output image, thus affecting its contrast.
 In general, r1 ≤ r2 and s1 ≤ s2 is assumed, so the function is always
increasing.

The effect of applying the transformation to every pixel of f to generate the


corresponding pixels in g would:
Produce higher contrast than the original image, by:
• Darkening the levels below m in the original
image
• Brightening the levels above m in the
original image
Two popular types of contrast stretching techniques are basic stretching contrast
and end-in-search.
Basic stretching contrast works well on the image where all the pixels concentrate
in one part of the histogram, for example in the middle.
Besides, contrast stretching is used to overcome deficiencies or excess light
during shooting, extending the distribution of pixel-gray values, where images
are usually grouped in: low contrast, fine contrast or normal contrast, and high
contrast. The image with low contrast is characterized by most of its bright or
mostly dark image composition.

The histogram shows some degree of grayness in groups together. If the pixel
grouping is on the left, then the image tends to be dark and vice versa. The image
with low quality can be improved quality with contrast stretching operation.

The contrast stretching algorithm is as follows:


1. Find the lower bound of pixel grouping by scanning the histogram of the
smallest gray scale to the largest gray scale value (0 to 255) to create the first
pixel that exceeds the predefined threshold value.
2. Find the upper border of pixel grouping by scanning the histogram of the
largest gray scale value to the smallest value of the predefined second threshold
value.
3. The pixels below the first threshold value are given a value of 0, while the
pixels above the second threshold value are 255.
4. The pixels between the first threshold value and the second scaled threshold
value to satisfy the complete range of gray scale values (0 to 255) with the
mathematical in

where r is the gray scale value of the original image, s is the new gray scale value,
the lowest gray scale r min value of the pixel group, the highest gray scale r max of
the pixel group.
B. Bit Plane Slicing Method

The low contrast image is strengthened using the image enhancement method.
Often the image enhancement method brightens all pixels of input image. This
weakness is usually overcome by using bit plane slicing.
Bit-plane slicing:
• Pixels are digital numbers composed of bits.
• 256 gray level image composed of 8 bits
• It can highlight the contribution made to total image appearance by specific
bits.
• Each pixel in an image represented by 8 bits.
• 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.
• Bits that are in bit plane 0 are categorized as least significant bits and the
bits in plane 7 bit are categorized as the most significant bits.
Consider the pixels that are bounded within the yellow line. The binary formats
for those values are (8-bit representation)

 The binary format for the pixel value 167 is 10100111


 Similarly, for 144 it is 10010000
 This 8-bit image is composed of eight 1-bit planes.
 Plane 1 contains the lowest order bit of all the pixels in the image.

 And plane 8 contains the highest order bit of all the pixels in the image
A=[167 133 111
144 140 135
159 154 148]
B=bitget(A,1); %Lowest order bit of all pixels
‘bitget’ is a MATLAB function used to fetch a bit from the specified position
from all the pixels.
B=[1 1 1
001
1 0 0]
B=bitget(A,8);%Highest order bit of all pixels
B=[1 1 0
111
1 1 1]

C. Intensity Level Slicing Method

Intensity level slicing method often highlights a certain range of desired gray
level imagery. The application includes improving certain features such as water
masses in satellite imagery and flaws in X-ray imagery.
Highlights a specific range of grey levels
• Similar to thresholding
• Other levels can be suppressed or maintained
• Useful for highlighting features
in an image

Histogram

• Histogram is a graphical representation showing a visual impression of


the distribution of data.
• An Image Histogram is a type of histogram that acts as a graphical
representation of the lightness/color distribution in a digital image. It
plots the number of pixels for each value.
• Histograms are the basis for numerous spatial domain processing
techniques
• Histogram manipulation can be used effectively for image enhancement
• Histograms can be used to provide useful image statistics
• Information derived from histograms are quite useful in other image
processing applications, such as image compression and segmentation.

Histogram Processing
nk: Number of pixels with gray value rk
n: total Number of pixels in the image
The function p(rk) represents the fraction of the total number of pixels with gray
value rk.

The shape of the histogram of an image gives us useful information about the possibility for
contrast enhancement.

Histogram equalization:
 The histogram equalization is an approach to enhance a given image. The
approach is to design a transformation T(.) such that the gray values in the
output is uniformly distributed in [0, 1].
 Let us assume for the moment that the input image to be enhanced has
continuous gray values, with r = 0 representing black and r = 1
representing white.
 We need to design a gray value transformation s = T(r), based on the
histogram of the input image, which will enhance the image.
Histogram Specification:Refer ppt & https://www.youtube.com/watch?v=nwIT4HJrKXs

You might also like