You are on page 1of 12

Module # 5

Image segmentation
Image segmentation is an important and challenging process of image processing. Image
segmentation technique is used to partition an image into meaningful parts having similar
features and properties. The main aim of segmentation is simplification i.e. representing an
image into meaningful and easily analyzable way. Image segmentation is necessary first step in
image analysis. The goal of image segmentation is to divide an image into several parts/segments
having similar features or attributes. The basic applications of image segmentation are: Content-
based image retrieval, Medical imaging, Object detection and Recognition Tasks, Automatic
traffic control systems and Video surveillance, etc. The image segmentation can be classified
into two basic types: Local segmentation (concerned with specific part or region of image) and
Global segmentation (concerned with segmenting the whole image, consisting of large number
of pixels). The image segmentation approaches can be categorized into two types based on
properties of image.

Image segmentation :

 A process of dividing a digital image into different segments. If one views an image as
depicting a scene composed of different objects, regions, etc. then segmentation is the
decomposition of an image into these objects and regions by associating or “labelling”
each pixel with the object that it corresponds to.
 Segmentation algorithms are based on one of the 2 basic properties of intensity values:
discontinuity and similarity.
 Discontinuity detection based approach
o This is the approach in which an image is segmented into regions based on
discontinuity. The edge detection based segmentation falls in this category in
which edges formed due to intensity discontinuity are detected and linked to form
boundaries of regions.
 Similarity detection based approach
o This is the approach in which an image is segmented into regions based on
similarity. The techniques that falls under this approach are: thresholding
techniques, region growing techniques and region splitting and merging. These all
divide the image into regions having similar set of pixels. The clustering
techniques also use this methodology. These divide the image into set of clusters
having similar features based on some predefined criteria.
 In other words, also we can say that image segmentation can be approached from three
perspectives: Region approach, Edge approach and Data clustering. The region approach
falls under similarity detection and edge detection and boundary detection falls under
discontinuity detection. Clustering techniques are also under similarity detection
 In the first category, the approach is to partition an image based on abrupt changes in
intensity, such as edges in an image.
 2nd category is based on partitioning an image into regions that are similar according to a
set of predefined criteria. Thresholding, region growing and region splitting and merging
are examples of methods in this category

 Let R represent the entire spatial region occupied by an image. Image segmentation is a
process that partitions R into n sub-regions, R1, R2, …, Rn, such that
Detection of discontinuities:
3 basic types of gray level discontinuities are points, lines and edges. First and second
derivatives are used for detecting these.

Point detection:
► First-order derivatives generally produce thicker edges in image
► Second-order derivatives have a stronger response to fine detail, such as thin lines,
isolated points, and noise
► Second-order derivatives produce a double-edge response at ramp and step transition in
intensity
► The sign of the second derivative can be used to determine whether a transition into an
edge is from light to dark or dark to light
► Lapalcian operator is used for detecting isolated points.

2 f 2 f
 2 f ( x, y )  
x 2 y 2
► Lapalcian mask is given by
 f ( x  1, y )  f ( x  1, y )  f ( x, y  1)  f ( x, y  1)
4 f ( x, y )

► The idea is that an isolated point (a point whose gray level is significantly different and
which is located in a homogenous or nearly homogeneous area) will bequite different
from its surroundings and thus be easily detectable by this type of mask.

Line detection:
► Second derivatives to result in a stronger response and to produce thinner lines than first
derivatives
► Double-line effect of the second derivative must be handled properly
► Line detection masks are given by
► Line detection mask has higher values along the orientation of the line.

Edge detection:
► Edges are pixels where the brightness function changes abruptly. An edge is a set of
connected pixels that lie on the boundary between 2 regions.
► An ideal edge is shown in fig. 10.8(a). It is purely vertical. In practice, due to image
acquisition imperfections, edges get blurred with the degree of blurriness being
determined by factors such as the quality of the image acquisition system, the sampling
rate and illumination conditions under which the image is acquired. These leads to
“ramplike” edges such as shown in (b). the slope of the ramp is inversely propotional to
the degree of blurring in the edge.
► First derivative is positive at the points of transition into an out of the ramp as we move
from left to right along the profile; it is constant along the ramp.
► Second derivative is positive at the onset and negative at the offset of the ramp and zero
along the ramp. Therefore there is a zero crossing in between.
► Basic Edge Detection by Using First-Order Derivative

 f 
 g x   x 
f  grad ( f )      
 g y   f 
 y 
The magnitude of f
M ( x, y )  mag(f )  g x 2  g y 2
The direction of f
 gx 
 ( x, y )  tan 1  
 g y 
The direction of the edge
   - 90

 f 
 x   x 
g
Edge normal: f  grad ( f )      
 g y   f 
 y 
Edge unit normal: f / mag(f )
In practice,sometimes the magnitude is approximated by
f f  f f 
mag(f )= + or mag(f )=max  | |,| | 
x y  x y 

► Laplacian generally is not used in its original form for edge detection for several reasons:
► As the second derivative is unacceptable sensitive to noise
► Magnitude of this produces double edges
► It is combined with smoothing as a precursor to finding edges via zero crossings.
Consider the function
𝑟2
− 2
𝐺(𝑟) = 𝑒 2𝜎
2 2 2
where 𝑟 = 𝑥 + 𝑦 and σ is the standard deviation.
► The Laplacian of ‘G’ is given by
2
𝑟 2 − 𝜎 2 − 𝑟 22
∇ 𝐺(𝑟) = − [ ] 𝑒 2𝜎
𝜎4
► The above function is commonly referred to as the ‘Laplacian of Gaussian (LoG)”
because the above equation is in the form of a Gaussian function. LoG mask is given by
Segmentation by thresholding:
 Here, we are dividing the whole image according to predetermined threshold.
 Histogram based approach. Threshold is usually selected as gray level values.
 We can select one or more threshold values according to the nature of the image
histogram and our application.
 For example, if the image f(x, y) composed of light objects on a dark background, in such
a way that object and background pixels have gray levels grouped into 2 dominant
modes. One obvious way to extract the objects form the background is to select a
threshold T that separates these modes. Then any point (x, y) for which f(x, y)>T is called
an object point; otherwise, the point is called a background point. This is shown in the
first figure.
 If we are using only one threshold, the formulation is as given below.
0; 𝑖𝑓 𝑓(𝑥, 𝑦) ≤ 𝑇, 𝑡ℎ𝑒 𝑏𝑎𝑐𝑘𝑔𝑟𝑜𝑢𝑛𝑑
𝑔(𝑥, 𝑦) = {
𝑓(𝑥, 𝑦); 𝑖𝑓 𝑓(𝑥, 𝑦) > 𝑇, 𝑡ℎ𝑒 𝑜𝑏𝑗𝑒𝑐𝑡

Where, f(x, y) is the original image and T is the predetermined threshold.

 If more than 2 dominant modes or more than 2 different regions are there, then multiple
thresholds are required. For example in second figure, 3 modes are there. Therefor 2
thresholds are required for separating out the regions. Eg:
0 𝑜𝑟 255; 𝑖𝑓 𝑓(𝑥, 𝑦) ≤ 𝑇1
𝑔(𝑥, 𝑦) = {𝑓(𝑥𝑦); 𝑖𝑓 𝑇1 ≤ 𝑓(𝑥, 𝑦) ≤ 𝑇2
255 𝑜𝑟 0; 𝑖𝑓 𝑓(𝑥, 𝑦) > 𝑇1

 Thresholding may be viewed as an operation that involves tests against a function T of


the form
𝑇 = 𝑇[𝑥, 𝑦, 𝑝(𝑥, 𝑦), 𝑓(𝑥, 𝑦)]
Where f(x, y) is the gray level value at point (x, y) and p(x, y) denotes some local
property of this point, for example, the average gray level value of a neighborhood
centered at (x, y). For example,

0; 𝑖𝑓 𝑓(𝑥, 𝑦) ≤ 𝑇
𝑔(𝑥, 𝑦) = {
1; 𝑖𝑓 𝑓(𝑥, 𝑦) > 𝑇
gives rise to a black and white image.
 When T depends only on f(x, y), the threshold is called global. If T depends on both f(x,
y) and p(x, y), the threshold is called local. In addition, if T depends also on x and y, the
threshold is called dynamic or adaptive.

Basic global thresholding:


 Simplest of all thresholding techniques. Partition the image histogram by using a single
global threshold T
 The following algorithm can be used to obtain T automatically:
 Select an initial estimate for T
 Segment the image using T. This will produce 2 pixel groups: G1 consisting of all pixels
with gray level values >T and G2 consisting of pixels with values less than or equal to T.
 Compute the average gray level values m1 and m2 for the pixels in regions G1 and G2
 Compute the new threshold.
𝑚1 + 𝑚2
𝑇=
2
 Repeat steps 2 through 4 until the difference in T in successive iterations is smaller than a
predefined parameter T0.

Questions:

1. What do you mean by image segmentation?


2. Explain image segmentation by Thresholding.

References:

1. “Digital image processing”, by Gonzalez and Woods


Title: Region based mage segmentation

Explanation:

Region based segmentation:

 Segmenting the region of interest.


 Different methods are there.
o Region growing
o Region splitting/merging

Region growing:

 At first we have to identify the region of interest.


 Next analyse the property of that region.
 Take a gray level value from that region.
 Then compare all other gray level values to the above value.
 If there is a match, group those values until the entire region is obtained.

Region splitting/merging:

 At first, the whole image is divided into different sub-images.


 Then find out whether 2 regions have equal properties.
 If a match is found, then merge those two regions to obtain the new set as in the figure.
 The process repeats until the whole image is segmented according to our application.

Questions:
1. What do you mean by region based image segmentation?
2. Explain the different types of region based image segmentation.

References:

1. “Digital image processing”, by Gonzalez and Woods


Clustering Based Segmentation Method:
The clustering based techniques are the techniques, which segment the image into clusters
having pixels with similar characteristics. Data clustering is the method that divides the data
elements into clusters such that elements in same cluster are more similar to each other than
others. There are two basic categories of clustering methods: Hierarchical method and Partition
based method. The hierarchical methods are based on the concept of trees. In this the root of the
tree represents the whole database and the internal nodes represent the clusters. On the other side
the partition based methods use optimization methods iteratively to minimize an objective
function. In between these two methods there are various algorithms to find clusters. There are
basic two types of clustering.

1) Hard Clustering: Hard clustering is a simple clustering technique that divides the image into
set of clusters such that one pixel can only belong to only one cluster. In other words it can be
said that each pixel can belong to exactly one cluster. These methods use membership functions
having values either 1 or 0 i.e. one either certain pixel can belong to particular cluster or not. An
example of a hard clustering based technique is one k-means clustering based technique known
as HCM. In this technique, first of all the centers are computed then each pixel is assigned to
nearest center. It emphasizes on maximizing the intra cluster similarity and also minimizing the
inter cluster equality.

2) Soft clustering: The soft clustering is more natural type of clustering because in real life exact
division is not possible due to the presence of noise. Thus soft clustering techniques are most
useful for image segmentation in which division is not strict. The example of such type of
technique is fuzzy c-means clustering. In this technique pixels are partitioned into clusters based
on partial membership i.e. one pixel can belong to more than one clusters and this degree of
belonging is described by membership values. This technique is more flexible than other
techniques.

You might also like