Mod 5-part 1
Image enhancement
• Enhancing an image provides better contrast and a
more detailed image as compared to non enhanced
image.
• It is used to enhance medical images, images captured
in remote sensing, images from satellite etc.
• The transformation function given as
s=T(r)
where r is the pixels of the input image and s is the pixels
of the output image. T is a transformation function that
maps each value of r to each value of s.
Gray level transformation
There are three basic gray level transformation.
• Linear
• Logarithmic
• Power – law
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.
• During log transformation,
=> Expand the values of dark pixels in an image
while compressing the higher-level values
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.
• 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)
Mod 5-part 2
Edge detection
• An image processing technique for finding the
boundaries of objects within images.
• It works by detecting discontinuities in brightness
• Used for image segmentation and data extraction
in areas like image processing, computer vision etc
• Generally edges are of three types:
Horizontal edges
Vertical Edges
Diagonal Edges
Edge detection methods
• Prewitt Operator
• Sobel Operator
All these masks find edges. Some find horizontally and
vertically, some find in one direction only and some find
in all the directions.
• Prewitt Operator : Prewitt operator is used for
detecting edges horizontally and vertically.
• Sobel Operator: The Sobel operator is very similar to
Prewitt operator. It is also a derivate mask which
calculates edges in both horizontal and vertical
direction.
Prewitt Operator
• It detects two types of edges: Horizontal edges &
Vertical Edges
• Edges are calculated by using difference between
corresponding pixel intensities of an image.
• Changes in a image can only be calculated using
differentiation. So that's why these operators are
also called as derivative operators or derivative
mask
All the derivative masks should have the following
properties:
o Opposite sign should be present in the mask.
o Sum of mask should be equal to zero.
o More weight means more edge detection
• Prewitt operator provides us two masks one for
detecting edges in horizontal direction and another for
detecting edges in an vertical direction.
Edge Detection
Sobel operator
•Very similar to Prewitt operator.
•Edges
also detects two types of edges: Horizontal edges & Vertical
•pixel
Edges are calculated by using difference between corresponding
intensities of an image.
•masks
Major difference is that in Sobel operator the coefficients of
are not fixed and they can be adjusted according to our
requirement unless they do not violate any property of
derivative masks.
•direction
provides us two masks one for detecting edges in horizontal
and another for detecting edges in an vertical
direction.
•This mask works exactly same as the
Edge Detection Prewitt operator vertical mask.
Sobel operator
•There is only one difference that is it
has “2” and “-2” values in center of
•Vertical
direction
first and third column. When applied
on an image this mask will highlight
the vertical edges.
•It simply works like as first order
derivate and calculates the difference
of pixel intensities in a edge region.
•As the center column is of zero so it
does not include the original values
of an image but rather it calculates
the difference of right and left pixel
values around that edge.
•This give more weightage to the pixel
values around the edge region. This
increase the edge intensity and it
•Above mask will find edges in horizontal direction
Edge Detectionand it is because that zeros column is in
horizontal direction.
Sobel operator •When you will convolve this mask onto an image
•Horizontal
direction
it would prominent horizontal edges in the
image.
•The only difference between it is that it have 2
and -2 as a center element of first and third row.
•As the center row of mask is consist of zeros so it
does not include the original values of edge in the
image but rather it calculate the difference of
above and below pixel intensities of the
particular edge.
•Thus increasing the sudden change of intensities
and making the edge more visible.
•Also if you compare the result of sobel operator
with Prewitt operator, you will find that sobel
operator finds more edges or make edges more
visible as compared to Prewitt Operator.
•This is because in sobel operator we have allotted
more weight to the pixel intensities around
Edge Detection
Sobel operator
•weighted
there is no fixed coefficients in sobel operator, so here is another
operator
•because
This will give out more edges as compared to previous mask
we have allotted more weight in the mask
Mod 5-part 3
Smoothing Filters
Smoothing linear Order statistics
filters(mean filters) filter(Non linear filter)
Averaging Weighted Minimum Maximum Median filter
filter averaging filter filter filter
Module - 5 (Image Enhancement in Spatial Domain and Image Segmentation)
Basic gray level transformation functions - Log transformations, Power-Law
transformations
Contrast stretching. Histogram equalization. Basics of spatial filtering - Smoothing
spatial filter-Linear and nonlinear filters, and Sharpening spatial filters-Gradient and
Laplacian.
Fundamentals of Image Segmentation. Thresholding - Basics of Intensity
thresholding and Global Thresholding. Region based Approach - Region Growing,
Region Splitting and Merging.
Edge Detection - Edge Operators- Sobel and Prewitt.
Gray level histogram
• 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
intensity value.
• Histogram of images provide a global
description of their appearance.
• Histogram of an image represents relative
frequency of occurrence of various gray
levels.
Grey level pixel value
Gray level histogram
Why Histograms?
• 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.
Gray level histogram
Types of Histograms
Gray level histogram
Types of Histograms
• In dark Image the components of the histogram are concentrated on the low (dark) side
of gray scale
• The components of the histogram of the bright image are biased toward the high side
of gray scale.
• A low contrast image histogram will be narrow and centered towards the middle of the
gray scale.
• The last graph is the best image; a high contrast image.
• Aim is to transform the first 3 histograms into the 4th type. That is try to increase the
dynamic range of the image .This is called Histogram Processing
Gray level histogram
Histogram Processing
• There are two methods of enhancing contrast.
Histogram Stretching/Contrast stretching
Histogram Equalization
Histogram Processing - Histogram Stretching
• Process of histogram stretching increases the dynamic range of the image and hence improves
the contrast of the image.
• In this process, the basic shape of the histogram is not modified, but the entire range of image
of histogram values is stretched.
• Limit values depends on type of image. (eg: 8 bit image ,limit values ranges between 0 & 255)
• Simplest histogram function: S = T(r) = ((Smax-Smin) / (rmax-rmin)) (r - rmin) + Smin
Smax– maximum limit value of image,
Smin– minimum limit value of image,
rmax– highest pixel value of image,
rmin– lowest pixel value of image
Histogram Processing - Histogram Stretching
Histogram Processing - Histogram Stretching
Histogram Processing - Histogram Equalization
• Equalization is a process that attempts to spread out the gray levels in an image so
that they are evenly distributed across their range.
• It reassigns the brightness values of pixels based on image histogram.
• The histogram of resultant image is made as flat as possible.
• Provides more visually pleasing results across a wide range of images.
Steps to perform Histogram Equalization:-
Find the running sum of histogram values.
Normalize the values from step1 by dividing by the total number of pixels
Multiply the values from step 2 by the maximum gray level value and round
Map the gray level values to the results from step 3 using a one to one
correspondence.
Histogram Processing - Histogram Equalization
• Example:
Q. Perform histogram equalization of the image.
• Maximum value is found to be 5. We need a minimum of 3 bits to represent the
number.
• There are 8 possible gray levels from 0 to 7
• Histogram of input image:-
Histogram Processing - Histogram Equalization
Step1: Compute the running sum of histogram values.
• Running sum is otherwise known as Cumulative Frequency Distribution(CFD).
Histogram Processing - Histogram Equalization
Step 2 : Divide the running sum obtained in step1 by the total number of pixels
(which is 25 in this case).
Histogram Processing - Histogram Equalization
Step3: Multiply the values from step 2 by the maximum gray level value
(which is 7 in this case). The result is then rounded to closest integer.
Histogram Processing - Histogram Equalization
Step 4: Map the gray level values to the results from step 3 using a one to one
correspondence
Tutorial :- Histogram Equalization
Tutorial :- Histogram Equalization
Assignment topic
Thresholding
Thresholding
Assumptions:
1. the intensity values are different in different regions
2. within each region, which represents the corresponding object in a scene,
the intensity values are similar
3. the range of intensity levels covered by objects of interest is different from
the
background
Types of Thresholding
Global or Fixed Thresholding:
A threshold value is selected where the threshold value depends only on
the pixel
intensities in the image. In fixed (or global) thresholding, the threshold
value is held
constant throughout the image.
Dynamic or Adaptive or Local thresholding:
Threshold depends on pixel value and pixel position (both f(x,y) and p(x,y).
So, the threshold for different pixels in the image will be different. The
image is
divided into overlapping sections which are thresholded one by one.
Optimal thresholding: estimate that how much is the error incorporated if
we choose a particular threshold. Then, you choose that value of the
threshold whereby which your average error will be minimized.
Basic Global Thresholding
Global Thresholding with T midway Global Thresholding with T estimated
between the maximum and minimum by iteration
gray levels
Intensity Thresholding
Image Binarization applies often just one global threshold T for mapping a
Scalar image I into a Binary image.
The global threshold can be identified by an optimization strategy aiming at
creating “large” connected regions and at reducing the number of
small‐sized
regions (artifacts).
Most frequently employed method for determining threshold is based on
histogram analysis of intensity level s.
Thresholding
Thresholding