Image Segmentation
Image Segmentation
Image Segmentation
1
Image Segmentation
Segmentation subdivides an image into its regions
or objects
2
Point, Line and Edge Detection
Points, Lines and Edges are three types of intensity
discontinuities in a digital image
Common way to find discontinuities is to pass a
mask through the image
For a 3×3 mask the response of the mask is given
by R = w1z1 + w2z2 + ….. + w9z9
Where zi is the intensity of the pixel associated with
mask coefficient wi
Response of the mask is defined with respect to its
center
3
Point Detection
4
Point Detection
Laplacian mask used for point detection
w = [-1 -1 -1; -1 8 -1; -1 -1 -1]
g = abs(imfilter(double(f), w);
T = max(g(:));
g = g >= T;
imshow(g)
A B
A: Image with nearly invisible isolated black point in the dark
area of the northeast quadrant
B: Detected point
5
Line Detection
Lines are detected using the following masks
8
Edge Detectors Available in Function edge
9
Some edge detector masks and first order
derivatives they implement
10
Prewitt Edge Detector
Prewitt edge detector uses the mask shown below
to approximate digitally the first derivatives G x and
Gy
11
Roberts Edge Detector
Roberts edge detector uses the mask shown below to
approximate digitally the first derivatives Gx and Gy
13
Laplacian of a Gaussian (LoG) Detector
Laplacian of this function with respect to r is
14
Laplacian of a Gaussian (LoG) Detector
LoG detector has two effects
1. It smoothens the image reducing noise
2. It computes the Laplacian, which yields a double-
edge .
15
Zero-Crossing Detector
16
Canny Edge Detector
Most powerful edge detector provided by function
edge
18
Thresholding
19
Thresholding
Suppose that intensity histogram corresponds to an
image f(x, y) composed of light object on a dark
background
21
Function graythresh
Function graythresh takes an image, computes its
histogram and then finds the threshold value that
maximizes the σ2.
Threshold is returned as a normalized value
between 0.0 and 1.0
Syntax T = graythresh(f)
23
Region-Based Segmentation
24
Region Growing
25
Function regiongrow
Function regiongrow is used to do the region
growing
Syntax [g, NR, SI, TI] = regiongrow (f, S, T)
27
Function roipoly
To specify a polygonal ROI interactively use the
syntax B = roipoly(f)
28
Function roipoly
To obtain the binary image and a list of the polygon
vertices, use the syntax
[B, c, r] = roipoly(f)
29
Function histroi
Function histroi computes the histogram of an
image within a polygonal region whose vertices are
specified by vectors c and r.
30
Generating Histogram of an ROI
31
Function statmoments
Function statmoments computes the mean and
central moments up to order n
Syntax [v, unv] = statmoments(h, n)
where p is the histogram vector and n is number of
moments to compute. Normalized values are given
in v, actual values are given in unv.
Mean and variance of the region masked by B can
be obtained as
>> [v, unv] = statmoments(h, 2);
>> v % Display the normalized values
>> unv % Display the actual values
32