Chapter 6 Image Segmentation 1 - 240827 - 072524
Chapter 6 Image Segmentation 1 - 240827 - 072524
Introduction:
Image segmentation is a method in which a digital image is broken down into
various subgroups called Image segments which helps in reducing the complexity
of the image to make further processing or analysis of the image simpler.
For example: Let’s take a problem where the picture has to be provided as input for
object detection. Rather than processing the whole image, the detector can be
inputted with a region selected by a segmentation algorithm. This will prevent the
detector from processing the whole image thereby reducing inference time.
Point detection
Line detection
Edge detection
Point Detection:
A point is the most basic type of discontinuity in a digital image. The most
common approach to finding discontinuities is to run an (n X n) mask over each
point in the image. The mask is as shown in figure bellow
Where Z is the response of the mask at any point in the image and T is non-
negative threshold value.
For Example:
Line Detection
Edge detection
Since isolated points and lines of unitary pixel thickness are infrequent in most
practical application, edge detection is the most common approach in gray level
discontinuity segmentation. An edge is a boundary between two regions having
distinct intensity level. It is very useful in detecting of discontinuity in an image,
when the image changes from dark to white or vice-versa.
Step edge: Transition of intensity level over 1 pixel only in ideal, or few pixels on
a more practical use
The first order derivative or gradient based filter such as Robert-cross, Prewitt, and
Sobel operators are prefers for detecting thicker lines.
The second order derivative such as Laplacian is prefers for detecting thinner lines.
By using one of this filter mask, we can perform convolution operation on input
image to calculate g(x) and g(y).
Prewitt Operator
By using one of this filter mask, we can perform convolution operation on input
image to calculate g(x) and g(y).
Sobel Operator
This method also takes the central difference of the neighboring pixels. It provides
both a differentiating and a smoothing effect.
By using one of this filter mask, we can perform convolution operation on input
image to calculate g(x) and g(y).
Edge Linking:
Ideally, edge detection should yield sets of pixels lying only on edges. In practice,
these pixels rarely characterize edges completely because of non-uniform
illumination, noise and breaks in the edges. Therefore, edge detection typically is
followed by linking algorithms designed to assemble edge pixels into meaningful
edges and/or region boundaries.
All points that are similar according to predefined criteria are linked, forming an
edge of pixels that share common properties.
Often, the location of regions of interest is known and pixel membership to regions
is available. Approximation of the region boundary by fitting a polygon.
Requirements
Two starting points must be specified (e.g. rightmost and leftmost points).
The points must be ordered (e.g. clockwise).
Variations of the algorithm handle both open and closed curves.
Given the end points A and B, compute the straight line AB. Compute the
perpendicular distance from all other points to this line. If this distance exceeds a
threshold, the corresponding point C having the maximum distance from AB is
declared a vertex. Compute lines AC and CB and continue.
Hough Transform
The Hough Transform is an algorithm patented by Paul V. C. Hough and was
originally invented to recognize complex lines in photographs (Hough, 1962).
Since its inception, the algorithm has been modified and enhanced to be able to
recognize other shapes such as circles and quadrilaterals of specific types.
Equation of line is
y = mx + c
A single point can be a part of infinite line. Therefore we transform that point in
the x-y plane, into a line in the m-c plane.
If A and B are two points connected by a line in the special domain, they will be
intercepting line in the Hough space.
All three lines are intercept in single point (1,1) that means all points (1,2) (2,3)
(3,4) are collinear and they are part of the same line.
By Lec. Pratik Chand, NCCS Page 11
Image Processing – CSIT 5th Semester
Thresholding
The simplest method for segmentation in image processing is the threshold
method. It divides the pixels in an image by comparing the pixel’s intensity with a
specified value (threshold). It is useful when the required object has a higher
intensity than the background (unnecessary parts).
You can consider the threshold value (T) to be a constant but it would only work if
the image has very little noise (unnecessary information and data). You can keep
the threshold value constant or dynamic according to your requirements.
Here in histogram, the region greater than T is object and less than T is
background.
The histogram bellow shows the thresholding problem involving three dominant
modes. For example two objects on a dark background.
Global Thresholding:
A constant threshold value is apply for both object and background is called global
thresholding. In this method, you replace the image’s pixels with either white or
black.
If the intensity of a pixel at a particular position is less than the threshold value,
you’d replace it with black. On the other hand, if it’s higher than the threshold,
you’d replace it with white.
5 3 9
2 1 7
8 4 2
Solution:
Calculate the threshold value T0 by taking average of all the pixel value
T0 = (5+3+9+2+1+7+8+4+2)/9
T0 = 4.55 = 5
G1 = {9,7,8}
μ1 = (9+7+8)/3
μ1 = 8
G2 = {5,3,2,1,4,2}
μ2 = (5+3+2+1+4+2)/6
= 2.83
μ2 = 3
T1= ½ (8+3)
T1= 5.5 = 6
So, again segment the image using new threshild value of T1 i.e. 6,
G1 = {9,7,8}
μ1 = 8
G2 = {5,3,2,1,4,2}
μ2= 3
T2 = ½ (8+3)
T2 = 5.5 = 6
Here the threshold value for successive iteration is same, so final value of T is 6,
which is the global threshold value.
Adaptive Thresholding
If T depends on special coordinates (x,y) themselves, then variable thresholding is
called dynamic or adaptive thresholding.
Having one constant threshold value might not be a suitable approach to take with
every image. Different images have different backgrounds and conditions which
affect their properties.
Thus, instead of using one constant threshold value for performing segmentation
on the entire image, you can keep the threshold value variable. In this technique,
you’ll keep different threshold values for different sections of an image.
This method works well with images that have varying lighting conditions. You’ll
need to use an algorithm that segments the image into smaller sections and
calculates the threshold value for each of them.
Region-Based Segmentation
Region-based segmentation algorithms divide the image into sections with similar
features. These regions are only a group of pixels and the algorithm find these
groups by first locating a seed point which could be a small section or a large
portion of the input image.
After finding the seed points, a region-based segmentation algorithm would either
add more pixels to them or shrink them, so it can merge them with other seed
points.
Based on these two methods, we can classify region-based segmentation into the
following categories:
Region Growing
In this method, you start with a small set of pixels and then start iteratively
merging more pixels according to particular similarity conditions. A region
growing algorithm would pick an arbitrary seed pixel in the image, compare it with
the neighbor pixels and start increasing the region by finding matches to the seed
point.
When a particular region can’t grow further, the algorithm will pick another seed
pixel which might not belong to any existing region. One region can have too
many attributes causing it to take over most of the image. To avoid such an error,
region growing algorithms grow multiple regions at the same time.
You should use region growing algorithms for images that have a lot of noise as
the noise would make it difficult to find edges or use thresholding algorithms.
Else
Leave as it is
Example: Apply region growing on following image with seed point at (2, 2) and
threshold value as 2.
0 1 2 0
2 5 6 1
1 4 7 8
0 9 5 1
Solution:
The possible pixel values which satisfy the condition are {5,6,7,8,9}
Now, let’s say region A which is denoted by 1 for condition satisfied values and
region B which is denoted by 0 for other values
0 0 0 0
0 1 1 0
0 0 1 1
0 1 1 0
It would first split the image into regions that have similar attributes and merge the
adjacent portions which are similar to one another. In region splitting, the
algorithm considers the entire image, while in region growth, the algorithm would
focus on a particular point.
The region splitting and merging method follows a divide and conquer
methodology. It divides the image into different portions and then matches them
according to its predetermined conditions. Another name for the algorithms that
perform this task is split-merge algorithms.
Example: Apply split and merge in given image. The threshold value is 3.
Solution:
Here, given T = 3
(7 – 0) > 3
Now, merging
Check the condition ((max1 – min2) <= T && (max2 – min1) <= T )
In the resulted image we can see two regions one is shaded region and another is
un-shaded region.
End of Unit-6