DIP - Module 4
DIP - Module 4
18CS741
[As per Choice Based Credit System (CBCS) scheme]
(Effective from the academic year 2018 -2019)
SEMESTER – VII
MODULE 4
Notes
Prepared By
Athmaranjan K
Associate Professor
Dept. of Information Science & Eng.
Srinivas Institute of Technology, Mangaluru
MODULE 4
SYLLABUS
Image Segmentation: Introduction, Detection of isolated points, line detection, Edge detection, Edge
linking, Region based segmentation- Region growing, split and merge technique, local processing, regional
processing, Hough transform, Segmentation using Threshold.
Textbook 1: Rafael C G., Woods R E. and Eddins S L, Digital Image Processing, Prentice Hall, 2nd edition,
2008
Textbook 1: Ch.10.1 to 10.3
IMAGE SEGMENTATION
INTRODUCTION:
So far we saw image processing methods whose input and output are images, but now let us see those
methods in which the inputs are images, but the outputs are attributes extracted from those images.
Segmentation subdivides an image into its constituent regions or objects.
The level to which the subdivision is carried depends on the problem being solved. Segmentation should stop
when the objects of interest have been isolated. Segmentation accuracy determines the eventual success or
failure of computerized analysis procedures. Hence, care should be taken to improve the probability of
segmentation.
In industrial inspection applications, at least some measure of control over the environment is possible at
times. The experienced image processing system designer invariably pays considerable attention to such
opportunities. In other applications, such as autonomous target acquisition, the system designer has no
control of the environment. Then the usual approach is to focus on selecting the types of sensors which could
enhance the objects of interest while diminishing the contribution of irrelevant image detail.
E.g.: the use of infrared imaging by the military to detect objects with strong heat signatures, such as
equipment and troops in motion.
After a successful segmenting the image, the contours of objects can be extracted using edge
detection and/or border following techniques.
Shape of objects can be described.
Based on shape, texture, and colour objects can be identified.
Image segmentation techniques are extensively used in similarity searches
IMAGE SEGMENTATION
What is image segmentation?
Image segmentation is a commonly used technique in digital image processing and analysis to partition an
image into multiple parts or regions, based on the characteristics of the pixels in the image.
The goal of Image segmentation is to simplify and/or change the representation of an image into something
that is more meaningful and easier to analyze.
CLASSIFICATION OF IMAGE SEGMENTATION TECHNIQUES
Image Segmentation algorithms are based on one of two basic properties of intensity values:
1. Discontinuity: It is an approach to partition an image based on abrupt changes in intensity, such as
edges in an image
3 x 3 Mask is superimposed with a 3 x 3 region of an image (the z’s are gray-level values) shown below:
Here the procedures (convolution) involves in computation of sum of products of the mask coefficients (wi)
with the gray levels (zi) contained in the region encompassed by the mask. Therefore by applying the
convolution process we get the response of the mask at any point in the image and is given by:
Where zi is the gray level of the pixel associated with mask coefficient wi. As usual the response of the mask
is defined with respect to its center location.
POINT DETECTION:
*******Explain detection of isolated points
An isolated point is a point whose gray level is significantly different from its background in a homogeneous
area.
Example: Any dark spot in white background or white spot in dark background, in an image can be observed
as an isolated point.
To identify the availability of any isolated point in image we must select the threshold value. The threshold
value is denoted by T, which is used to identify the points. We say that a point has been detected at the
location f(x, y) on which the mask is centered if the absolute value of the response of the mask at that point
exceeds a specified threshold. Such points are labelled 1 in the output image and all others are labelled 0,
thus producing a binary image.
Again apply these masks on the given image (refer the input image with zi’s are gray-level values) and then
superimpose and convolution process is being applied and accordingly we have to calculate the response of
the mask. The response of the mask is given by:
Here R1 is the response when moving the mask from left to right and R2 is the response when moving the
mask from top to bottom. Similarly R3 is the response of the mask along +450 line and R4 is the response of
the mask along -450 line.
Suppose that an image is filtered (individually) with the four masks. If, at a given point in the image;
That point is said to me more likely associated with a line in the direction of mask k.
Example: if at a point in the image response R1 of a mask,
That particular point is said to be more likely associated with a horizontal line.
EDGE DETECTION:
Edge detection is a fundamental tool in image processing and computer vision, particularly in the areas of
feature detection and feature extraction, which aim at identifying points in a digital image at which the image
brightness changes sharply or more formally has discontinuities.
3. Edge localization; steps involves in determining the exact location of edge in an image, and also it
involves in edge thinning and edge linking steps, so that edges can be viewed in a sharp and
connected manner. .
These two equations can be implemented for all pertinent values of x and y by filtering f(x, y) with the 1-D
masks as shown below:
Magnitude:
By using the above formula we calculate magnitude and direction of gradient. Thus the gradient of an image
measures the change in image function f(x, y) in X and Y directions.
An edge can be extracted by computing the derivative of the image function where magnitude of the
derivative indicates the strength or contrast of edge.
Direction of the derivative vector indicates the edge orientation.
A 3 x 3 region of an image (the z’s are gray-level values) and masks used to compute the gradient at point labeled
z5 is shown below:
Robert operator
PREWITT OPERATOR
The above Masks of size 2 x 2 are difficult to implement as they do not have clear center. So an approach by
using Prewitt operator masks of size 3 x 3 is calculated for the given image;
Gx = (z7 +z8 + z9) – (z1 +z2 + z3)
Here the difference between first and third rows of the 3 X 3 image region approximates the
derivative in x direction, and
The difference between third and first columns approximates the derivative in y direction.
Thus the prewitt operator provides us two masks one for detecting edges in the horizontal direction and
another for detecting edges in a vertical direction.
The masks shown below is called Prewitt operator:
SOBEL OPERATOR
It is a first order derivative estimators in which we can specify whether the edge detector is sensitive to
horizontal or vertical edges or both. It provides both a differentiating and smoothing effect. It also relies on
central differences.
A weight value of 2 is used to achieve some smoothing by giving more importance to the centre point.
Gx =
Gy =
SOBEL OPERATOR
By using the mask gradient of image intensity at each pixel within the image is calculated. It finds the
direction of the largest increase from light to dark and the rate of change in that direction..
PREWITT AND SOBEL MASK FOR DETECTING DIAGONAL EDGES
Explain gradient operators with respect to prewitt and sobel mask for detecting diagonal edges.
The two additional prewitt and sobel masks for detecting discontinuities in the diagonal directions are shown
below:
And {direction f(x, y) – direction f(x0, y0)} < A ; where A is a non-negative angle threshold
The direction of edge at f(x, y) is perpendicular to the direction of gradient vector at that point.
The magnitude of gradient is;
An edge point in the pre-defined neighborhood of (x, y) is link to the pixel at (x, y) if both magnitude and
direction criteria are satisfied. This process is repeated at every location in the image. A record must be kept
of linked points as the centre of the neighbourhood is moved from pixel to pixel and assign a different
intensity value to each set of linked edge pixels.
HOUGH TRANSFORM
***************Explain Hough Transform in edge linking OR
****Describe the procedure for detecting lines using Hough Transform
The Hough transform is a feature extraction method used to detect simple shapes such as lines, circles and
objects in an image using the concept of parameter space. Hough transform is used to connect the disjoined
edges in image.
A simple shape is one that can be represented by only few parameters. For example;
A line can be represented by two parameters such as slope and intercept and
A circle has three parameters such as coordinates of the center (x, y) and radius (r)
Hough transform does an excellent job in finding such shapes in an image.
Working Principle:
Consider any point (xi, yi) on xy plane and the general equation of a straight line in slope-intercept form is
given by:
yi = axi + b
Infinitely many lines pass through this (xi, yi) but they all satisfy the equation yi = axi + b for varying values
of a and b.
A line in xy plane contains many points on it. We need to transfer this line from xy plane to ab plane using
the equation; b = -axi + yi.
In fact, all the points on this line have lines in parameter (Hough) space that intersect at point (a’, b’).
Let us consider a line in xy plane which contains two points (xi, yi) and (xj, yj) as shown below:
When we convert this line to parameter (Hough) space we get two lines intersecting at point (a’, b’) unless
these two lines are parallel where a’ is the slope and b’ is the intercept of the line containing both (xi, yi) and
(xj, yj) in the xy plane.
Thus all the edge points; say (x1, y1), (x2, y2), (x3, y3), ……… lie on the line only if their corresponding lines
intersect at one common point in parameter space. This is what Hough transform does; for each edge point
we draw the lines in the parameter space and then find their point of intersection (if any). The intersection
point will give us the parameter (slope and intercept) of the line.
Drawback:
A practical difficulty with this approach, however, is that a (the slope of a line) approaches infinity as the line
approaches the vertical direction. One way around this difficulty is to use the normal representation of a line:
THRESHOLDING
Thresholding is the simplest method of image segmentation, where we change the pixels of an image to make
the image easier to analyze. In thresholding, we convert an image from colour or grayscale into a binary
image,
Thresholding is carried out with the assumption that the range of intensity levels covered by objects of
interest is different from the background.
Steps involved in thresholding:
1. A threshold T is selected
2. Any point (x, y) in the image at which f(x, y) > T is called an object point otherwise background
point.
3. The segmented image denoted by g(x, y);
Suppose that the gray level histogram corresponding to an image f(x, y), composed of light objects on dark
background. In such a way that object and background pixels have gray levels grouped into two dominant
modes.
• Here multilevel thresholding classifies a point (x, y) as belonging to one object class if
Thus the thresholding is a very important technique for image segment. It provides uniform regions based on
the threshold value T. Key parameter of thresholding process is the choice of threshold value.
Discuss image segmentation using Thresholding in detail.
Thresholding is carried out with the assumption that the range of intensity levels covered by objects of
interest is different from the background.
Steps involved in thresholding:
1. A threshold T is selected
2. Any point (x, y) in the image at which f(x, y) > T is called an object point otherwise background
point.
3. The segmented image denoted by g(x, y);
Types of Thresholding
1. Global Thresholding: Threshold operation depend upon only gray scale value f(x, y), where T is
constant value.
Global Thresholding:
The simplest of all thresholding techniques is to partition the image histogram by using single global
threshold T as shown below
Here the gray level histogram corresponding to an image f(x, y), composed of light objects on dark
background. In such a way that object and background pixels have gray levels grouped into two dominant
modes.
The following algorithm can be used to obtain global threshold value T automatically:
1. Select an initial estimate for T (This value should be greater than the minimum and less than the
maximum intensity levels in the image. It is better to choose the average intensity of an image.
2. Segment the image using T: This will produce 2 groups of pixels; G1: consisting of all pixels with
gray level values > T and G2 consisting of pixel values ≤ T
3. Compute the average gray level values μ1 and μ2 for the pixels in regions G1 and G2
4. Compute a new threshold value:
5. Repeat steps 2 through 4 until the difference in T in successive iterations is smaller than a predefined
parameter T0
Dynamic or Adaptive Thresholding
One approach to reduce the effect of non-uniform illumination in image segmentation is to divide the original
image into sub-images and then utilize a different threshold to segment each sub image. Key issues in this
approach are how to sub divide the image and how to estimate the threshold for each resulting sub image.
Here, Q(Rk) is a logical predicate defined over the points in set Rk, and Ø is the null set. The symbols U and
Ո represent set union and intersection, respectively. Two regions and are said to be adjacent if their union
forms a connected set.
Condition (a) indicates that the segmentation must be complete; that is, every pixel must be in a
region.
Condition (b) requires that points in a region be connected in some predefined sense (e.g., the points
must be 4- or 8-connected).
Condition (c) indicates that the regions must be disjoint.
Condition (d) deals with the properties that must be satisfied by the pixels in a segmented region—for
example, Q(Ri) = TRUE if all pixels in Ri have the same intensity level.
Finally, condition (e) indicates that two adjacent regions Ri and Rj must be different in the sense of
predicate Q.
Thus Region-based segmentation approaches are based on partitioning an image into regions that are similar
according to a set of predefined criteria.
Advantages:
1. Region growing methods can correctly separate the regions that have the same properties we define.
2. Region growing methods can provide the original images which have clear edges the good
segmentation results.
3. The concept is simple. We only need a small numbers of seed point to represent the property we
want, then grow the region.
4. We can choose the multiple criteria at the same time.
5. It performs well with respect to noise, which means it has a good shape matching of its result.
Disadvantage:
1. The computation is time consuming,
2. This method may not distinguish the shading of the real images.
In conclusion, the region growing method has a good performance with the good shape matching and
connectivity. The most serious problem of region growing method is the time consuming.
1 1 9 9 9
1 1 9 9 9
5 1 1 9 9
5 5 5 3 9
3 3 3 3 3
Answer:
It is given that seed points are: 1, 3, 5 and 9 and we have to consider the 4 way connectivity criteria for
region growing.
Let us consider the initial seed points as:
1 1 9 9 9
1 1 9 9 9
5 1 1 9 9
5 5 5 3 9
3 3 3 3 3
Consider the 4-way adjacent (similar pixel) points with respect to these seed points
1 1 9 9 9
1 1 9 9 9
5 1 1 9 9
5 5 5 3 9
3 3 3 3 3
Repeat the above step until no more pixel is part of the region
Splitting:
Consider the entire image region and identify the maximum and minimum gray level values.
Maximum gray level value = 7
Minimum gray level value = 0
Consider the predicate P is the absolute difference of Max and Min gray level value ≤ Threshold value
|Max gray value –Min gray value| ≤ 3
|7 – 0| = 7 > 3
So the predicate P is FALSE; we need to split the image into 4 parts:
In region R1:
Max gray value = 7 and Min gray value = 4
P = |7- 4| ≤ 3 = TRUE ; So splitting of R1 is not required
ATHMARANJAN K DEPT OF ISE, SRINIVAS INSTITUTE OF TECHNOLOGY MANGALURU Page 23
DIGITAL IMAGE PROCESSING 18CS741 Module 4
In region R2:
Max gray value = 7 and Min gray value = 2
P = |7- 2| ≤ 3 = FALSE ; So we need to split the region R2 into 4 parts:
In region R3:
Max gray value = 3 and Min gray value =0
P = |3- 0| ≤ 3 = TRUE; so splitting of R3 is not required
In region R4:
Max gray value = 7 and Min gray value = 0
P = |7- 0| ≤ 3 = FALSE; so we need to split the region R4 into 4 parts:
Furthermore we will check all sub-regions, since all of them are having Predicate P ≤ 3; so no further
splitting is required
Merging:
Check adjacent regions if they are falling within the threshold then merge.
Consider region R1 and R11:
Max gray value = 7 and Min gray value =4
P = |7- 4| ≤ 3 = TRUE; so merge R1 with R11
Similarly region R1R21 and R22 can be merged into R1R21R22 region;
R1R21R22 and R23 is merged into R1R21R22R23 region
R1R21R22R23 and R42 is merged into R1R21R22R23R42 region
R1R21R22R23R42 and R43 is merged into R1R21R22R23R42R43 region.
Answer:
Let us start by considering the seed point as 6, from top left. Check the neighbouring pixels with respect this
seed point by using 8 -way connectivity and add those neighbouring pixels whose absolute gray level
difference with respect to seed point is ≤ 3.
Repeat the process for newly added pixels in which gray level value 6 is present. Thus the regions are grown
from the seed points to adjacent point depending on a threshold or criteria that we used.
Region growth should stop when no more pixels satisfy the criteria for inclusion in that region.
Initial seed point 8 way connectivity points with newly added pixels in which gray level
respect to seed point 6 value 6 is present and condition for
Threshold value is satisfied.
2 Explain the techniques for detecting three basic types of gray level discontinuities in a digital 10
image.
3 Explain detection of isolated points 5
4 Explain how line can be detected in a digital image, give masks for detection of horizontal 8
line, vertical line, left diagonal line and right diagonal line
5 With the help of Mask discuss Robert, Prewitt and Sobel edge detection methods 8