You are on page 1of 44

Image Enhancement in the Spatial

Domain

Digital Image Processing (DIP)

Lecture # 3
Topics for Today
• Image Enhancement
• Types of Image Enhancement
• Spatial Domain Operations
• Gray-Level Transformations (Identity , negative, log, power-law transform)
• Contrast Stretching
• Gray-Level slicing https://www.tutorialspoint.com/dip/gray_level_transfor
mations.htm
• Bit-Plane Slicing
• Image Histogram
What is purpose of image
enhancement
• Image enhancement is applied to process an image in a
way that it is more suitable than the original image for a
specific application.

• The word specific is important as a technique that is used


to improve the quality of X-RAY image will not be suitable
for picture of MARS.

• There is no general theory for image enhancement as


viewer is the ultimate judge to decide the better case.
Categories for image enhancement
• There are two categories for image
enhancement
1. Spatial domain/Time domain that refers to
the operations in image plane.
2. Frequency domain (also know as spectral
domain) that refers to the operations like
application of Fourier transformation on
image/frequency domain analysis.
What is spatial domain
• Spatial domain methods are the set of
procedures that are applied directly on the pixels
and they can be represented as

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

Here f(x,y)= image, g(x,y ) is the processed image


while T is the transformation performed
( like averaging of pixels, image negative etc)
Spatial Domain Operation
• In Spatial Domain operations we will deal with

1. Point Processing
2. Mask Processing
Point Processing/Single Point
Processing

Single-point processing is a simple method for image enhancement. This technique


determines a pixel value in the enhanced image dependent only on the value of the
corresponding pixel in the input image.
a) A narrow range of values are mapped to wider range This is the enhancement in this
case
b) The second operation is applying a thresholding technique applying on a binary image.
Mask Processing
• Larger neighborhoods allow considerably more flexibility. The
general approach is to use a function of the values of f in a
predefined neighborhood of (x, y) to determine the value of g
at (x, y)
Graph of Basic Gray-Level Image
Transformations
Gray level transformations
• Image Negative (3.2.1)
• Log Transformation (3.2.2)
• Power Law Transformation (3.2.3)

Image transformation are mathematically


expressed as
s=T (r)
where T= transformation that maps a pixel value r
into a value s
Image Negative
• The negative of an image with gray levels is
obtained by using negative transformation. This is
mathematically expressed as: In negative transformation, each
s=L-1-r value of the input image is subtracted
from the L-1 and mapped onto the
output image.

Reversing the intensity levels of an image in this


manner will produce an image that is equivalent
of photograph negative. This is required in the
case when information is required from a black
area.
Log Transformation
• The shape of the log curve in Fig. 3.3 shows that this
transformation maps a narrow range of low gray-
level values in the input image into a wider range of
output levels. The opposite is true of higher values
of input levels 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.

S= c*log (1+r)
Where c= constant and r≥0

During log transformation, the dark pixels in an image


are expanded as compared to the higher pixel
values. The higher pixel values are kind of
compressed in log transformation
The value of c in the log transform adjust the kind of enhancement
Dynamic range compression

The dynamic range of an image can be compressed by replacing each pixel value with
its logarithm. This has the effect that low intensity pixel values are enhanced. Applying
a pixel logarithm operator to an image can be useful in applications where the
dynamic range may too large to be displayed on a screen (that cannot handle a wider
range)
Power Law Transformation
S=C*R^γ

For GAMMA <1 for lower intensity values, it expands the dynamic range of very small
intensity of the input image while the higher intensity is mapped to the lower range of
intensity values in the processed image and reverse is applicable for the values of GAMMA
>1
GAMMA Correction
• Gamma correction is used in display devices
such as monitors, printers and capturing
devices etc and it is represented as
S=C*R ^1/γ
Input image is converted into power law
transform before it is produced so if a reverse
operation (gamma correction) is applied on
the image before its projection and as a
result it will be displayed properly.
GAMMA Correction
• Cathode Ray Tube (CRT) have an intensity to voltage response
that is in power transformation the value of GAMMA is varied
from 1.8-2.5 and it results in a darker image as shown below
• s=r^2.5= (Please refer to previous Fig for GAMMA=2.5)
• If we apply a gamma correction here then we will get
s=r ^ 1/2.5= r^0.4 (please refer to Fig for GAMMA=0.4)
GAMMA correction
Summary of Power Law
Transformation
• Power law transformation is not only used in display
technology, it is also used for image enhancement.
The advantage is
• The transformation curve get various shapes
depending on values of gamma.
• Gamma<1 on the darker side lower range of intensity
values are mapped to the larger (brighter) range of
intensity values while brighter intensity values are
mapped to the lower range of intensity values and
reverse is true for gamma>1
Example of Power law transformation
(Decrease in value of gamma)
Example of Power law transformation
(Increase in value of gamma)
Contrast Stretching
• 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, e.g. the full range
of pixel values that the image type concerned
allows.
Contrast Stretching
• Why contrast stretching?
• Image created from camera can be very dark as
illumination of scene or object can be poor.
• The dynamic range of camera senor can be very small
even if scene is properly illuminated
• Aperture (that allows light to pass through lens to
image) of the camera was small at the time of taking
snap.

The solution of these are to apply contrast stretching


by making the dynamic range of intensities high.
Definition of contrast stretching
This type of transformation is used to enhance
low contrast images. In a low contrast image
specific details are difficult to determine due
to the fact that most pixels are at the same
intensity value. Contrast stretching resolves
this problem by boosting the lighter pixels to a
higher intensity level, and doing exactly the
opposite to the lower intensity pixels.
Contrast Stretching

The points (r1,s1) and (r2,s2) are used to control the shape of this transformation
a) If r1=s1 and r2=s2 then it will be linear function indicating no change in gray values
with a slope value of 45 degree.
b) In this case for image enhancement using contrast stretching we need that following
r1≤r2 and s1 ≤s2

The condition preserve the order of gray scale values (a darker point in original image
will remain darker in the transformed image and vice versa) and it creates a difference
in intensities values.
Example of contrast stretching
Example of contrast stretching
Gray Level Slicing
no min or max value
• Highlight a specific range of gray scale levels
(instead of selecting the whole image) such as
enhancing flaws in X-Ray image or masses of
water in satellite imagery.
Example of Gray Level Slicing
Definition of Gray Level Slicing
Grey level slicing is the spatial domain
equivalent to band-pass filtering. A grey level
slicing function can either emphasize a group
of intensities and diminish all others or it can
emphasize a group of grey levels and leave the
rest alone.
what is difference between contrast stretching and gray
level slicing?
Digital negative is used to enhance white details in a dark background for medical
imaging applications. Thresholding and Contrast stretching techniques are applied
by stretching the grey levels of an image. Grey level slicing technique is applied to
some specified region in an image.
Bit-plane Slicing
• Instead of highlighting gray level images, highlighting
the contribution made to total image appearance by
specific bits might be desired.
• Suppose that each pixel in an image is represented
by 8 bits. Imagine the image is composed of 8, 1-bit
planes ranging from bit plane1-0 (LSB)to bit plane 7
(MSB).
• In terms of 8-bits, plane 0 contains all lowest order
bits in the bytes comprising the pixels in the image
and plane 7 contains all high order bits.
Bit-plane Slicing
Bit-plane Slicing
Bit-plane Slicing
Question
• How binary bits/ bit plane slicing are used to
enhance an image?
Example of Image divided into bit plane
Example of Image divided into bit
plane
General Concepts about Histogram
no of occurrence for a particular pixels
A histogram is a display of statistical
information that uses rectangles to show the
frequency of data items in successive
numerical intervals of equal size.
Image Histogram
• An image histogram is used to represent
the graphical representation of the intensities
in a digital image. It plots the number
of pixels for each value. By looking at the
histogram for a specific image a viewer will be
able to judge the entire tonal distribution at a
glance.
Comments about this image?
Comments about this image?
Comments about this image?
Comments about this image?
Examples of Image Histograms
Examples of Image Histograms

You might also like