You are on page 1of 60

DIGITAL IMAGE PROCESSING

Module 3

Image Enhancement

S6 EC KTU

KTUStudents.in
prepared by

Anjana Devi

For more study materials: WWW.KTUSTUDENTS.IN


Objective of image enhancement
 The goal of image enhancement is
 1)Improving the interpretability or visual perception of
information in images to improve visual appeal
2) highlighting interesting details in an image
3) Removing noise from images

KTUStudents.in
4)Providing `better' input for other automated image
processing techniques
 Done through
1) modification of intensity fns -spatial transforms
2) modification of image spectral content – freq
transforms
3) combination of 1) and 2).

For more study materials: WWW.KTUSTUDENTS.IN


Enhancement on 2 Domains
Image Enhancement can be performed in 2
domains
1)Spatial domain

KTUStudents.in
 The term spatial domain refers to the
aggregate of pixels composing an
image
 spatial domain transformations operate
directly on pixels
2)Freq domain
 operate on Fourier/Wavelet transform of an
image For more study materials: WWW.KTUSTUDENTS.IN
Spatial domain methods
1) Point operation or point processing
2) Mask/Area Processing/Spatial
filtering/neighbourhood operation

KTUStudents.in
3) Geometric Transformations
4} Frame Processing Transformation

For more study materials: WWW.KTUSTUDENTS.IN


Spatial domain methods- Area/Mask
Processing
Denoted by g(x,y)=T[f(x,y)]
 where f(x,y) = input image
 g(x,y) = processed image

KTUStudents.in
 T is the operator on f, defined over a
neighbourhood of (x,y)
 In addition,T can operate on a set of input
images, such as performing the pixel-by-
pixel sum of K images for noise
reduction.

For more study materials: WWW.KTUSTUDENTS.IN


Spatial TransformationArea/Mask
processing
Values of f in a predefined
neighborhood of (x, y) , ie, mask, is used
in the function to generate new image
– g(x,y)=T[f(x,y)]
Basically, a mask is a small (say, 3*3) 2-D array

KTUStudents.in
– also referred to as filters, kernels, templates,
or windows
Allows more flexibility in defining the
transformation functions
 Eg. image sharpening.
 Function used- filter
 the values of the filter/mask coefficients
determine the o/p
For more study materials: WWW.KTUSTUDENTS.IN
Spatial Transformation- Area/Mask
processing
The principal approach in defining a neighborhood about a
point (x, y) is to use a square or rectangular sub image
area centered at (x, y)

KTUStudents.in

Fig.2.1 A 3*3 neighborhood about a point (x, y) in


an image
For more study materials: WWW.KTUSTUDENTS.IN
Spatial Transformation- Area/Mask
processing
The operator T is applied at each location (x, y) to
yield the output, g, at that location.
The process utilizes only the pixels in the area of
the image spanned by the neighborhood.

KTUStudents.in
 Square and rectangular arrays are by far the most
predominant neighborhood shapes
 because of their ease of implementation
 Other neighborhood shapes, such as
approximations to a circle, are sometimes used

For more study materials: WWW.KTUSTUDENTS.IN


Point Processing
Enhancement at any point in an image depends only
on the gray level at that point and not on neighborhood
values
Simplest form of image transform
Equivalent to neighborhood of size 1*1 (that is, a
single pixel).

KTUStudents.in
 In this case, g depends only on the value of f at (x, y)
 T becomes a gray-level (also called an intensity/gray
level mapping) transformation function of the form
g = T(f)
• T independent of position (x,y)
ie, spatial information is completely lost
 Point processing used mainly for contrast
enhancement For more study materials: WWW.KTUSTUDENTS.IN
Spatial domain methods

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN


Spatial domain methods

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN


Two Egs for Simple Neighbourhood
Operations
Simple neighbourhood operations example:

– Min: Set the pixel value to the minimum in the


neighbourhood
KTUStudents.in
– Max: Set the pixel value to the maximum in the
neighbourhood

– These are non linear mask operations


– Detailed later

For more study materials: WWW.KTUSTUDENTS.IN


Point processing -Intensity/Gray level
transformation
 2 types -
 1) Linear Transformations and Piecewise Linear
Transformations
 2)Non Linear Transformations

KTUStudents.in
1)Linear gray level transformation
• maps each pixel gray level into another gray level
• i/p image- Linear Transformation -o/p
image
–g = T(f)
–Eg: Image negative and Identity Transformation

For more study materials: WWW.KTUSTUDENTS.IN


Basic Linear Transformations in point
processing
Identity Transformation
 output intensities are identical to input
intensities
Image Negatives:
The negative of an image with gray levels in the
KTUStudents.in
range [0, L-1] is obtained by the expression
s = L - 1 – r. where s – o/p pixel, r – i/p pixel value
Reversing the intensity levels of an image in this
manner produces the equivalent of a photographic
negative.
suited for enhancing white or gray detail embedded
in dark regions of an image, especially when the
black areas are dominant in size..
For more study materials: WWW.KTUSTUDENTS.IN
Spatial domain methods- Point
Processing –Linear Transformations

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN


Spatial domain methods- Point
Processing –Linear Transformations

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN


Negative(Invert)

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN


Negative

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN


3 Piecewise Linear Transformations
 Contrast stretching and Thresholding
 Gray-level slicing
 Bit-plane slicing
 Adv of piecewise linear transforms
 Can be applied on complex transform functions

KTUStudents.in
 a practical implementation of some important
transformations can be formulated only as piecewise
functions.
 The principal disadvantage of piecewise functions
 their specification requires considerably more user input

For more study materials: WWW.KTUSTUDENTS.IN


Piecewise Linear Transformations
 Contrast stretching/compression & Thresholding:
 One of the simplest piecewise linear functions is a contrast-stretching
transformation.
 To enhance low contrast images
 The idea behind contrast stretching is to increase the dynamic range

KTUStudents.in
of the gray levels in the image being processed
 The transformation function stretches the levels
linearly from their original range to the full range
[0,L-1].

 Low contrast images can result from


 poor illumination
 lack of dynamic range in the imaging sensor
 even wrong setting of a lens aperture during image acquisition.

For more study materials: WWW.KTUSTUDENTS.IN


Contrast Stretching/Compression
The locations of points (r1 , s1) and (r2 , s2)
control the shape of the transformation function.
1) If r1 = s1 and r2 = s2, the transformation is a
linear function that produces no changes in gray
levels.
2) Intermediate values of (r1 , s1) and (r2 , s2)

KTUStudents.in
produce various degrees of spread in the gray levels
of the output image, thus affecting its contrast
3) If r1= r2, s1= 0 and s2 = L-1, the transformation
becomes a thresholding function that creates a binary
image
In general, r1 ≤ r2 and s1 ≤ s2 is assumed so that
the function is single valued and monotonically
increasing.
This condition preserves the order of gray levels,
thus preventing the creation of intensity artifacts in
For more study materials: WWW.KTUSTUDENTS.IN
the processed image
Contrast
Stretching/compression

KTUStudents.in
a) Graylevel transformation functions for contrast
enhancement
m- mean gray level
b) Threshold function to produce binary image

For more study materials: WWW.KTUSTUDENTS.IN


Piecewise Linear Transformations
Contrast stretching

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN


Spatial domain methods- Point
Processing

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN


Contrast Stretching

KTUStudents.in

Contrast Stretching (a) Form of Transformation function (b) A low-


contrast image (c) Result of contrast stretching (d) Result of
thresholding For more study materials: WWW.KTUSTUDENTS.IN
Piecewise Linear Transformations-
contrast stretching
 Figure 1.3 (b) shows an 8-bit image with low contrast.
 Fig. 1.3(c) shows the result of contrast stretching,
obtained by setting (r1 , s1) = (r min , 0) and (r2 , s2) =
(r max , L-1) where r min and r max denote the
minimum and maximum gray levels in the image,
respectively.

KTUStudents.in
 Thus, the transformation function stretched the levels
linearly from their original range to the full range [0,L-1].
 Finally, Fig. 1.3 (d) shows the result of using the
thresholding function defined previously, with r1 < m,
the mean gray level in the image.
 The original image on which these results are based is a
scanning electron microscope image of pollen,magnified
approximately 700 times.

For more study materials: WWW.KTUSTUDENTS.IN


Piecewise Linear Transformations
 Contrast stretching & Thresholding:
 The effect of this transformation would be to produce an
image of higher contrast than the original by darkening the
levels below m and brightening the levels above m in the
original image.

KTUStudents.in
In this technique, the values of r below m are compressed
by the transformation function into a narrow range of s,
toward black.
The opposite effect takes place for values of r above m.
In the limiting case shown in Fig. (b), T(r) produces a two-
level (binary) image.
A mapping of this form is called a thresholding function.
For more study materials: WWW.KTUSTUDENTS.IN
Piecewise Linear Transformations-
Thresholding
One of the simplest operations we can perform on an image
is thresholding.

For example, if we take the swan image and threshold it with


a threshold of T,

KTUStudents.in
 we make all pixels >= T into 1,
 and all pixels < T into 0.

For more study materials: WWW.KTUSTUDENTS.IN


Threshold T=128

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN


Examples

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN


Summary

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN


Piecewise Linear Transformations-
Gray/Intensity level slicing
 Highlighting a specific range of gray levels in an image
 Applications
 enhancing features such as masses of water in
satellite imagery
 enhancing flaws in X-ray images

KTUStudents.in
 Two basic approaches for gray level slicing
 One approach is to display a high value for all
gray levels in the range of interest and a low
value for all other gray levels.
This transformation produces a binary
image.
 The second approach brightens the desired range of
gray levels but preserves the background and gray-level
tonalities in the image.
For more study materials: WWW.KTUSTUDENTS.IN
Gray level /Intensity Level Slicing

KTUStudents.in

(a) This transformation highlights range [A, B] of gray levels and reduce
all others to a constant level (b) This transformation highlights range [A,
B] but preserves allFor
other levels (c) An image (d) Result of using the
more study materials: WWW.KTUSTUDENTS.IN
transformation in (a).
Spatial domain methods- Point
Processing

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN


Piecewise Linear Transformations- Bit
plane slicing
 To Highlight the contribution made to total
image appearance by specific bits
Eg: 8 bits/pixel.
 image is composed of eight 1-bit planes, ranging from
bit-plane 0 for the least significant bit to bit plane 7

KTUStudents.in
for the most significant bit.
 plane 0 contains all the lowest order bits in the bytes
comprising the pixels in the image and plane 7
contains all the high-order bits

For more study materials: WWW.KTUSTUDENTS.IN


Bit Plane Slicing

KTUStudents.in

Bit-plane representation of an 8-bit image

For more study materials: WWW.KTUSTUDENTS.IN


Piecewise Linear Transformations- Bit
plane slicing
 Separating various bit planes for an image
illustrates that the higher-order bits
(especially the top four) contain the
majority of the visually significant data.
The other bit planes contribute to more subtle
details in the image.
KTUStudents.in
Separating a digital image into its bit planes
 useful for analyzing the relative
importance played by each bit of the
image,
 a process that aids in determining the
adequacy of the number of bits used to
quantize each pixel.
For more study materials: WWW.KTUSTUDENTS.IN
Bit Plane Slicing

KTUStudents.in

An 8-bit fractal image

For more study materials: WWW.KTUSTUDENTS.IN


Bit Plane Slicing

KTUStudents.in

An 8-bit fractal image

The eight bit planes of the above image The number at the
bottom, rightForofmore
eachstudy image identifies the bit plane.
materials: WWW.KTUSTUDENTS.IN
Basic Non Linear Transformations in
point processing

Log Transformations
 Log and inverse log
Power Law Transformations

KTUStudents.in
– nth power and nth root
Histogram Equalization

For more study materials: WWW.KTUSTUDENTS.IN


Intensity/Gray level transformation
2) Non linear gray level transformation
Log Transformations:

KTUStudents.in
where c is a constant, and it is assumed that
 r ≥ 0.

For more study materials: WWW.KTUSTUDENTS.IN


Spatial domain methods- Point
Processing

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN


Log Transformation
The shape of the log curve
– this transformation maps a narrow range of low
gray-level values of the input image into a wider
range of output levels.
– The opposite is true of higher values of input
KTUStudents.in
levels.
used to expand the values of dark pixels in an
image while compressing the higher-level
values.
The opposite is true of the inverse log
transformation.

For more study materials: WWW.KTUSTUDENTS.IN


Log Transformation
The log function has the important characteristic that
it compresses the dynamic range of images with
large variations in pixel values.
A classic illustration of an application in which pixel
values have a large dynamic range is the Fourier

KTUStudents.in
spectrum.
While processing numbers such as these presents
no problems for a computer
But image display systems generally will not be able
to reproduce faithfully such a wide range of intensity
values.
The net effect is that a significant degree of detail
will be lost in the display of a typical Fourier
spectrum For more study materials: WWW.KTUSTUDENTS.IN
Log Transform

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN


Difference between contrast stretching and
log transformation
Contrast stretching produces higher contrast by
Darkening the levels below m
Brightening the levels above m
Improves dynamic range

KTUStudents.in
Log Transformation
Compresses the large variations in pixel intensities of 0
to 10^6
Compresses dynamic range

For more study materials: WWW.KTUSTUDENTS.IN


Power Law/Exponential
Transformation
Power-law transformations have the basic form

where c and γ are positive constants.

KTUStudents.in
Sometimes Eq. is written as
to account for an offset (that is, a measurable output
when the input is zero).
Offsets are typically an issue of display calibration and
as a result they are normally ignored in Eq.

For more study materials: WWW.KTUSTUDENTS.IN


Spatial domain methods- Point
Processing- Power law Transformations

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN


Power law plots

KTUStudents.in

Plots of the equation for various values of (c=1 in


all cases).
For more study materials: WWW.KTUSTUDENTS.IN
Power Law Transformation
 Power-law curves with fractional values of γ (γ <1)
 Similar to the log transformation
– map a narrow range of dark input values into a wider
range of output values,
– the opposite is true for higher values of input levels.

KTUStudents.in
 curves generated with values of γ >1
 have exactly the opposite effect as those generated with
values of γ <1.
 map a wider range of dark input values into a narrow
range of output values
 Unlike the log function, here a family of possible
transformation curves are obtained simply by varying γ.
 Note that Eq. reduces to the identity transformation when c = γ =
1. For more study materials: WWW.KTUSTUDENTS.IN
Gamma correction/Why power laws are
popular?
 A variety of devices used for image capture, printing, and display respond according
to a power law.
 For example, cathode ray tube (CRT) devices have an intensity-to-voltage response
that is a power function
 Exponents of power function for display vary from approximately 1.8 to 2.5
• For a computer CRT, γ is about 2.2.

KTUStudents.in
 With reference to the curve for γ = 2.5 in Fig. we see that such display systems would
tend to produce images that are darker than intended
 By convention, the exponent γ in the power-law equation is referred to as gamma.
 Viewing images properly on monitors requires γ-correction
 The process used to correct the power-law response phenomena of display devices is
called gamma correction.
 Adjusting the value of γ suitably and transforming the image as per power
law transform before applying to the display devices
• Apply power law transformation with γ = 1/2.2 and apply the transformed pixel values
to the monitor.
For more study materials: WWW.KTUSTUDENTS.IN
Gamma Correction

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN


Power Law
Transformation

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN


Basic Point Processing Operations

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN


Spatial domain methods- Point
Processing- non linear Transformations

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN


Spatial domain methods- Point
Processing- Histogram

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN


Histogram

 In Statistics
 A plot of freq of occurrence of an image.
 Histogram is a graphical representation showing a visual
impression of the distribution of data.

KTUStudents.in
An Image Histogram
 A type of histogram that acts as a graphical representation of
the intensity/gray values/color distribution in a digital image.
 It plots the number of pixels for each gray /color value
 ie, relative freq of occurrence of each value

For more study materials: WWW.KTUSTUDENTS.IN


A simple image and its histogram

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN


Examples

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN


Examples

KTUStudents.in

For more study materials: WWW.KTUSTUDENTS.IN

You might also like