0% found this document useful (0 votes)
24 views61 pages

Module 5 Segmentation

The document discusses image segmentation and boundary representation, focusing on techniques for detecting discontinuities such as points, lines, and edges using various algorithms including the Laplacian and Canny edge detection. It outlines steps for edge detection, including image smoothing, gradient computation, and edge linking, as well as region-based segmentation methods like region growing and splitting. The content is structured for educational purposes, referencing key texts and detailing exam components.

Uploaded by

2022.surel.sanap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views61 pages

Module 5 Segmentation

The document discusses image segmentation and boundary representation, focusing on techniques for detecting discontinuities such as points, lines, and edges using various algorithms including the Laplacian and Canny edge detection. It outlines steps for edge detection, including image smoothing, gradient computation, and edge linking, as well as region-based segmentation methods like region growing and splitting. The content is structured for educational purposes, referencing key texts and detailing exam components.

Uploaded by

2022.surel.sanap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 61

Module -5

IMAGE SEGMENTATION and BOUNDARY REPRESENTATION

MR. MRUGENDRA VASMATKAR


Assistant Professor, EXTC
VES Institute of Technology
References

1. Gonzales and Woods, “Digital Image Processing”, Pearson Education,


India, Third Edition
1. Chapter -10- Image Segmentation
2.Digital image processing – Ramesh Jayraman
3.Digital Image processing – Sreedhar

Marks in Exam :- 30 Marks


Numerical - (books 1,2,3)
1. Chain code - 8M
2. Split and Merge algorithm – 6-8M
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation

(a) Image containing a region of constant intensity. (b) Image showing the boundary of the inner region, obtained from
intensity discontinuities. (c) Result of segmenting the image into two regions. (d) Image containing a textured region.
(e) Result of edge computations. Note the large number of small edges that are connected to the original boundary,
making it difficult to find a unique boundary using only edge information. (f) Result of segmentation based on region
Detection of Discontinuities

 There are three kinds of discontinuities of intensity: points,


lines and edges.
 The most common way to look for discontinuities is to scan a
small mask over the image. The mask determines which kind
of discontinuity to look for.
9
R w1 z1  w2 z 2  ...  w9 z9  wi zi
i 1

W1 W2 W3
W4 W5 W6
W7 W8 W9

Generalized 3x3 mask


Detection of Isolated Points

It is done by 2nd derivative i.e. Laplacian mask


1 1 1

1 -8 1

1 1 1
Find the location of the points as follows:

w=[-1 -1 -1; -1 8 -1; -1 -1 -1];


g=abs(imfilter ( double(f), w);
T=max(g(:));
g=g >=T;
imshow(g);
Laplacian for Line detection

(a) Original image.


(b) Laplacian
image; the
magnified section
shows the
positive/negative
double-line effect
characteristic of the
Laplacian.
(c) Absolute value
of the Laplacian.
(d) Positive values
of the Laplacian
Detection of Discontinuities
Line Detection
Detection of Discontinuities
Line Detection
Program
Detection of Discontinuities (a) Image of a
Line Detection wire-bond
template.
(b) Result of
processing with
the line
detector mask in
Fig. 10.6.
(c) Zoomed view
of the top left
region of (b).
(d) Zoomed view
of the bottom
right region of
(b). (e) The image
in (b) with all
negative values
set to zero. (f) All
points (in white)
whose values
satisfied the
condition
where g is the
image in (e).
Detection of Discontinuities
Edge Models

From left to right, models (ideal representations) of a step, a ramp,


and a roof edge, and their corresponding intensity profiles
Detection of Discontinuities
Edge Detection
Detection of Discontinuities
Edge Detection
(a) Two regions
of
constant intensity
separated by an
ideal vertical
ramp edge.
(b) Detail near
the edge, showing
a horizontal
intensity profile,
together with its
first and second
derivatives
Steps in edge detection

1. Image smoothing for noise reduction.

2. Detection of edge points. this is a local operation that extracts


from an image all points that are potential candidates to become
edge points.

3. Edge localization. The objective of this step is to select from the


candidate edge points only the points that are true members of the
set of points comprising an edge.
First column: Images and
intensity profiles of a ramp
edge corrupted by random
Gaussian noise of zero
mean and standard
deviations of 0.0, 0.1, 1.0,
and 10.0
intensity levels,
respectively.

Second column: First-


derivative images and
intensity profiles.

Third column: Second-


derivative images and
intensity profiles.
Detection of Discontinuities
Edge Detection
Detection of Discontinuities
Edge Detection
Detection of Discontinuities
Gradient Operators

• First-order derivatives:
– The gradient of an image f(x,y) at location (x,y) is defined
as the vector:
f
 Gx    x
f     f
 G y    y

x 
– The magnitude of this vector: f mag(f )  G 2  G 2
y  1
2

– The direction of this vector:  Gx 


 ( x, y ) tan  
1

 Gy 
Detection of Discontinuities
Gradient Operators

Roberts cross-gradient operators

Prewitt operators

Sobel operators
Detection of Discontinuities
Gradient Operators

Prewitt masks for


detecting diagonal edges

Sobel masks for


detecting diagonal edges
Detection of Discontinuities
Using Sobel Gradient Operators: Example

Original image -834x114 Sobel Gradient –X-direction |Gx|

|Sobel Gradient –Y-direction |Gy| |Gx| + |Gy| f  Gx  G y


Detection of Discontinuities
Using Sobel Gradient Operators: Example

Original
image
smoothened
by 5x5
averaging
mask
Detection of Discontinuities
Diagonal Gradient Operators: Example
Detection of Discontinuities
Combining the gradient with thresholding (33%)
Canny Edge Detection
 The algorithm is more complex,
 The performance of the Canny edge detector (Canny [1986]) is superior in general to the
edge detectors discussed earlier.
 Canny’s approach is based on three basic objectives:

1. Low error rate. All edges should be found, and there should be no spurious
responses. That is, the edges detected must be as close as possible to the true edges.

2. Edge points should be well localized. The edges located must be as close as possible
to the true edges. That is, the distance between a point marked as an edge by the
detector and the center of the true edge should be minimum.

3. Single edge point response. The detector should return only one point for each true
edge point. That is, the number of local maxima around the true edge should be
minimum. This means that the detector should not identify multiple edge pixels where
only a single edge point exists.

The essence of Canny’s work was in expressing the preceding three criteria
mathematically and then attempting to find optimal solutions to these
formulations.
In general, it is difficult (or impossible) to find a closed-form solution
STEP1 :Smooth the input image with a Gaussian filter.

1. Using numerical optimization with 1-D step edges corrupted by additive


white Gaussian noise
2. White noise is noise having a frequency spectrum that is Continuous and
uniform over a specified frequency band.
3. White Gaussian noise is noise in which the distribution of amplitude
values is Gaussian.
4. Gaussian white noise is a good approximation of many real-world
situations and generates mathematically tractable models.
5. It has the useful property that its values are statistically independent
6. A good approximation† to the optimal step edge detector is the first
derivative of Gaussian
STEP1 :Smooth the input image with a Gaussian filter

• Let f(x,y) is image and G(x,y) is Gaussian function

• We Form fs(x,y) by convolving G and f


Gradient operation

Using the gradient to determine edge strength and direction at a point. Note that the
edge is perpendicular to the direction of the gradient vector at the point where the
gradient is computed. Each square in the figure represents one pixel.
STEP 2:Compute the gradient magnitude and angle images.

• Generalizing this result to 2-D involves recognizing that the 1-D approach still
applies in the direction of the edge normal Because the direction of the normal
is unknown beforehand, this would require applying the 1-D edge detector in
all possible directions.
• This task can be approximated by first smoothing the image with a circular 2-D
Gaussian function, computing the gradient of the result, and then using the
gradient magnitude and direction to estimate edge strength and direction at
every point.
• computing the gradient magnitude and direction(angle)
STEP 3: Apply nonmaxima suppression to the gradient
magnitude image.

• The essence of the approach is to specify a number of discrete


orientations of the edge normal (gradient vector).
• For example, in a region we can define four orientations† for
an edge passing through the center point of the region:
horizontal, vertical, +45 degree and -45 degree
• Figure shows, if the edge normal is in the range of directions
from -22.5 degree and +22.5 degree or from -157.5 degree to
+157.5 degree we call the edge a horizontal edge
Canny Edge Detection
STEP-4: Use double thresholding and connectivity analysis
to detect and link edges

 If we set the threshold too low, there will still be some false
edges (called false positives).
 If the threshold is set too high, then actual valid edge points will
be eliminated (false negatives).
 Canny’s algorithm attempts to improve on this situation by using
hysteresis thresholding
 It uses two thresholds: a low threshold ,and a high threshold
 Canny suggested that the ratio of the high to low threshold
should be two or three to one.
 We can visualize the thresholding operation as creating two
additional images
STEP-4: Use double thresholding and connectivity analysis
to detect and link edges
(a) Original image of size pixels, with intensity values scaled to the range [0, 1].
(b) Thresholded gradient of smoothed image.
(c) Imageobtained using the Marr-Hildreth algorithm.
(d) Image obtained using the Canny algorithm.
Detection of Discontinuities
Gradient Operators

• Second-order derivatives: (The Laplacian)


– The Laplacian of an 2D function f(x,y) is defined as
2 2 f 2 f
 f  2  2
x y
– Two forms in practice:
Detection of Discontinuities
Gradient Operators

• Consider the function: A Gaussian function


r2

h(r )  e 2 2
where r 2  x 2  y 2
and  : the standard deviation
• The Laplacian of h is
r2 The Laplacian of a
2 r    2 2 
2 2
 h(r )   e Gaussian (LoG)
 
4

• The Laplacian of a Gaussian sometimes is called the Mexican
hat function. It also can be computed by smoothing the image
with the Gaussian smoothing mask, followed by application of
the Laplacian mask.
Detection of Discontinuities
Gradient Operators
Detection of Discontinuities
Gradient Operators: Example

Sobel gradient

Gaussian smooth function Laplacian mask


Detection of Discontinuities
Gradient Operators: Example
Edge Linking and Boundary Detection
Local Processing

• Two properties of edge points are useful for edge linking:


– the strength (or magnitude) of the detected edge points
– their directions (determined from gradient directions)
• This is usually done in local neighborhoods.
• Adjacent edge points with similar magnitude and direction are
linked.
• For example, an edge pixel with coordinates (x0,y0) in a
predefined neighborhood of (x,y) is similar to the pixel at (x,y)
if
f ( x, y )  ( x0 , y0 ) E , E : a nonnegative threshold
 ( x, y )   ( x0 , y0 )  A, A : a nonegative angle threshold
Edge Linking and Boundary Detection
Local Processing: Example

In this example,
we can find the
license plate
candidate after
edge linking
process.
Thresholding

• Assumption: the range of intensity levels covered by objects


of interest is different from the background.

1 if f ( x, y )  T
g ( x, y ) 
0 if f ( x, y ) T

Single threshold Multiple threshold


The role of noise in image thresholding

(a) Noiseless 8-bit image.


(b) Image with additive Gaussian noise of mean 0 and standard deviation of 10
intensity levels.
(c) Image with additive Gaussian noise of mean 0 and standard deviation of 50
intensity levels.
(d)–(f) Corresponding histograms.
Thresholding
The Role of Illumination
Thresholding
The Role of Illumination

r ( x, y ) (a) (c) i ( x, y )

(d) (e)

f ( x, y ) i ( x, y )r ( x, y )
Thresholding
Basic Global Thresholding
Region-Based Segmentation
Region-Based Segmentation
Region Growing
Region-Based Segmentation
Basic Formulation

• Let R represent the entire image region.


• Segmentation is a process that partitions R into subregions,
R1,R2,…,Rn, such that
n
(a)  Ri R
i 1
(b) Ri is a connected region, i 1,2,..., n
(c) Ri  R j  for all i and j , i  j
(d) P ( Ri ) TRUE for i 1,2,..., n
(e) P( Ri  R j ) FALSE for any adjacent regions Ri and R j
where P(Rk): a logical predicate defined over the points in set Rk
For example: P(Rk)=TRUE if all pixels in Rk have the same gray
level.
Region-Based Segmentation
Region Growing
Region-Based Segmentation
Region Growing

• Fig. 10.41 shows the histogram of Fig. 10.40 (a). It is difficult


to segment the defects by thresholding methods. (Applying
region growing methods are better in this case.)

Figure 10.40(a) Figure 10.41


Region-Based Segmentation
Region Splitting and Merging

• Region splitting is the opposite of region growing.


– First there is a large region (possible the entire image).
– Then a predicate (measurement) is used to determine if the
region is uniform.
– If not, then the method requires that the region be split into
two regions.
– Then each of these two regions is independently tested by
the predicate (measurement).
– This procedure continues until all resulting regions are
uniform.
Region-Based Segmentation
Region Splitting and Merging

• The main problem with region splitting is determining where to


split a region.
• One method to divide a region is to use a quadtree structure.
• Quadtree: a tree in which nodes have exactly four descendants.
Region-Based Segmentation
Region Splitting and Merging

• The split and merge procedure:


– Split into four disjoint quadrants any region Ri for which
P(Ri) = FALSE.
– Merge any adjacent regions Rj and Rk for which P(RjURk) =
TRUE. (the quadtree structure may not be preserved)
– Stop when no further merging or splitting is possible.
END

You might also like