You are on page 1of 36

EEE F435 (2023-24-I)

Digital Image Processing


(Image Segmentation)
BITS Pilani
K K Birla Goa Campus
Ashish Chittora
(Isolated) Point detection
• Laplacian operator

• It highlights the isolated points in image


• Sensitive to very fine detail and noise
• Responds equally to strong and weak edges
• Uniform regions/ constant intensity appear black
Line detection
• Operator

• Hough transform for detection of straight lines


Edge models
Edge detection
• Gradient-based edge operators
– Prewitt
– Sobel
– Roberts
• Laplacian zero-crossings
• Canny edge detector
Edge detection operators
Examples: Roberts
Examples: Prewitt
Hough Transform
• Generalized template matching technique
• Problem: fit a straight line (or curve) to a set of edge pixels

• Using the line equation y=ax+b


• Rewriting the equation in parameter space :
b=-xa+y
(now x, y are constants, a is a variable, b is a function
of a)
Properties
• Each point (xi , yi) defines a line in the a-b space
(parameter space)
• Points lying on the same line in the x-y space,
define lines in the parameter space which all
intersect at the same point
• The coordinates of the point of intersection
define the parameters of the line in the x-y
space
Algorithm
• Quantize/Subdivide the parameter (a,b) plane into discrete
“bins,” initialize all bin counts by 0
• Draw a line in the parameter space [a,b] for each edge pixel
[x,y] and increment bin counts along line.
• Detect peak(s) in [a,b] plane
Hough Transform
• Problem with slope-intercept equation
- The slope can become very large or even infinity
- It will be impossible to quantize such a large space
• Solution :
– Use polar representation of line equation (Similar to Radon transform)

x cos  y sin   
Example: Hough Transform

Image space Parameter space


Example: Hough Transform
Example: Hough Transform
Algorithm: Hough Transform
• Quantize the parameter space
• Set all cells to zero initially
• For every non-background point in x-y plane,
Θ equals each subdivision on Θ-axis, and solve
for corresponding ρ
• Resulting ρ - value are rounded to nearest cell
value along ρ-axis
• A(p,q)=A(p,q)+1
• A value P in cell A(i,j) means P-
number of points in x-y plane
lie on same line
Hough transform extension
• Hough transform can also be used for detecting
circles, ellipses, etc.
For example, the equation of circle:
In this case, there are three parameters: (x0, y0), r
• In general, we can use hough transform to detect
any curve which can be described analytically by
an equation of the form:
g(v,C) (v: vector of coordinates, C: parameters)
• Detecting arbitrary shapes, with no analytical
description, is also possible
(Generalized Hough Transform)
Image segmentation
Grey-level thresholding
p(x)

0.02

Background
Object
0.01

x
0.00
1 T 2
Gray Scale Image - bimodal

Image of rice with black background

Image histogram of rice

Image after segmentation


Multimodal Histogram
• If there are three or more dominant modes in the
image histogram, the histogram has to be partitioned
by multiple thresholds.

• Multilevel thresholding classifies a point (x,y) as


belonging to one object class
if T1 < (x,y) <= T2,
to the other object class
if f(x,y) > T2
and to the background
if f(x,y) <= T1.
Gray Scale Image - Multimodal

Original Image

Histogram

Image after segmentation


Adaptive Thresholding Bimodal Histograms
• Adaptive Thresholding (automatic) algorithm:
1)Select an initial estimate for Ti
2)Segment the image using Ti. This will produce two groups of
pixels. G1 consisting of all pixels with gray level values >Ti and G2
consisting of pixels with values <=Ti.
3)Compute the average gray level values mean μ1 and μ2 for the
pixels in regions G1 and G2.
4)Compute a new threshold value
T(i+1)=(μ1 + μ 2) / 2
5)Repeat steps 2 through 4 until difference in T in successive
iterations is smaller than a predefined parameter T0.
Region Based Segmentation Techniques
Region growing
Step1. We start with a number of seed points which have been clustered into n
clusters, called C1, C2, …,Cn. And the positions of initial seed points is set as p1, p2,
…, p3.
Step2. To compute the difference of pixel value of the initial seed point pi and its
neighbouring points, if the difference is smaller than the threshold (criterion) we
define, the neighbouring point could be classified into Ci, where i = 1, 2, …,n.
Step3. Recompute the boundary of Ci and set those boundary points as new seed
points pi (s). In addition, the mean pixel values of Ci have to be recomputed,
respectively.
Step4. Repeat Step2 and 3 until all pixels in image have been allocated to a suitable
cluster.
Region splitting and merging
Region splitting and merging
Region splitting and merging
Region splitting and merging
Region splitting and merging
Region splitting and merging
Region splitting and merging
Region splitting and merging
MATLAB exercises
• Line detection and edge detection using
different operators (prewitt, sobel, laplacian)
Useful functions: edge(), fspecial(), imfilter()
• Hough transform example : hough()
• Grey-level thresholding : greythresh()
• Region growing
Thank you

You might also like