At the end of this lesson, you should be able to;
describe Connected Components and Contours in image segmentation.
discuss region based segmentation method.
discuss Region Growing segmentation technique.
discuss Morphological Watersheds segmentation.
discuss Model Based Segmentation.
discuss Motion Segmentation.
implement connected components, flood fill, watershed, template matching and frame difference techniques.
formulate possible mechanisms to propose segmentation methods to solve problems.
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Segmentation Techniques -II
1. COMPUTER GRAPHICS & IMAGE PROCESSING
COM2304
Segmentation Techniques -II
K.A.S.H.Kulathilake
B.Sc. (Hons) IT (SLIIT), MCS (UCSC)
Rajarata University of Sri Lanka
Faculty of Applied Sciences
Department of Physical Sciences
2. Learning Outcomes
COM 2304 - Computer Graphics & Image
Processing
• At the end of this lecture, you should be able to;
– describe Connected Components and Contours in
image segmentation.
– discuss region based segmentation method.
– discuss Region Growing segmentation technique.
– discuss Morphological Watersheds segmentation.
– discuss Model Based Segmentation.
– discuss Motion Segmentation.
– implement connected components, flood fill,
watershed, template matching and frame difference
techniques.
– formulate possible mechanisms to propose
segmentation methods to solve problems.
2
3. Connected Components & Contours
• Let S represent subset of pixels in
an image.
• Two pixels p and q are said to be
connected in S if there exist a
path between them consisting
entirely of pixels in S.
• For any pixel p in S, the set of
pixels that are connected to it in
S is called a connected
component of S.
• If it only has one connected
component, then set is
called connected set.
COM 2304 - Computer Graphics & Image
Processing
3
4. Connected Components & Contours
(Cont…)
• Contours are sequences of points defining a
line/curve in an image.
• Contour matching can be used to classify
image objects.
COM 2304 - Computer Graphics & Image
Processing
4
6. Region Based Segmentation
• The main idea here is to classify a particular
image into a number of regions or classes.
• Thus for each pixel in the image we need to
somehow decide or estimate which class it
belongs to.
• There are a variety of approaches to do region
based segmentation.
COM 2304 - Computer Graphics & Image
Processing
6
7. Region Growing
• Region growing is a procedure that groups
pixels or sub regions into larger regions based
on pre-defined criteria for growth.
• Region growing algorithms utilize the concept
of size, likeness between a candidate pixel and
the pixel grown so far and the shape of the
region being grown.
COM 2304 - Computer Graphics & Image
Processing
7
8. Region Growing (Cont…)
• Properties of region grown algorithms:
– Seed point:
• It starts with a set of “seed” points and from these grow regions by appending
to each seed those neighboring pixels that have predefined properties similar
to the seed.
• Selecting one or a set of seed points can be based on the nature of the
problem.
– Selection of similarity criteria:
• It depends not only on the problem under consideration, but also on the type
of image data available.
– Connectivity:
• descriptors alone can yield misleading results if connectivity properties are not
used in the region growing process.
– Stopping Rule:
• Region growing should stop when no more pixels satisfy the criteria for
inclusion in that region.
COM 2304 - Computer Graphics & Image
Processing
8
9. Region Growing (Cont…)
• Algorithm
Let f(x, y) denote the input image array; s(x, y) denote a seed array
containing 1s at the locations of seed points and 0s elsewhere; and
Q denote a predicate to be applied at each location (x, y). f(x,y)
and s(x, y) are in same size and algorithm based on 8-connectivity.
1. Find all connected components in s(x, y) and erode each connected
component to 1 pixel; label all such pixels found as 1. All other pixels
in are labeled 0.
2. Form an image fQ such that, at a pair of coordinates (x, y), let
fQ(x,y)=1 if the input image satisfies the given predicate Q, at those
coordinates; otherwise, let fQ (x, y) = 0.
3. Let g be an image formed by appending to each seed point in S all
the 1-valued points in fQ that are 8-connected to that seed point.
4. Label each connected component in g with a different region label
(e.g. 1, 2, 3, ….). This is the segmented image obtained by the region
growing.
COM 2304 - Computer Graphics & Image
Processing
9
10. Region Growing (Cont…)
• Flood Fill
– It is useful to mark or isolate potions of an image
for further processing or analysis.
– In flood fill method a seed point is selected from
an image and then all similar neighboring points
are colored with a uniform color.
– The result of a flood fill operation will always be a
single contiguous region.
COM 2304 - Computer Graphics & Image
Processing
10
11. Region Growing (Cont…)
COM 2304 - Computer Graphics & Image
Processing
11
Original Image Enhanced Image Remove non
uniform illumination and salt and
pepper noise
12. Region Growing (Cont…)
COM 2304 - Computer Graphics & Image
Processing
12
Apply morphological operation to
obtained the connectivity
Background subtraction to reduce
over segmentation
13. Region Growing (Cont…)
COM 2304 - Computer Graphics & Image
Processing
13
Flood Fill to extract foreground Extracted foreground
14. Region Growing (Cont…)
COM 2304 - Computer Graphics & Image
Processing
14
Binary image of extracted foreground Original image for comparison
15. Morphological Watersheds
• Any grayscale image can be
viewed as a topographic
surface where high intensity
denotes peaks and hills while
low intensity denotes valleys.
• You start filling every isolated
valleys (local minima) with
different colored water
(labels).
• As the water rises, depending
on the peaks (gradients)
nearby, water from different
valleys, obviously with
different colors will start to
merge.
COM 2304 - Computer Graphics & Image
Processing
15
16. Morphological Watersheds (Cont…)
• To avoid that, you build barriers in the locations
where water merges.
• You continue the work of filling water and
building barriers until all the peaks are under
water.
• Then the barriers you created gives you the
segmentation result.
• visit :
http://cmm.ensmp.fr/~beucher/wtshed.html for
animation
COM 2304 - Computer Graphics & Image
Processing
16
17. Morphological Watersheds (Cont…)
• This segmentation method used to extraction of
nearly uniform (blob like) objects from the
background.
• Region characterized by small variations in intensity
have small gradient values.
• Thus, in practice we often see watershed
segmentation applied to the gradient of an image,
rather than to the image itself.
• In this formulation, the regional minima of the
catchment basins correlate nicely with the small
value of the gradient corresponding to the objects of
interest.
17
COM 2304 - Computer Graphics & Image
Processing
18. Morphological Watersheds (Cont…)
• Three types of points
– Points belonging to a regional minimum
– Catchment basin / watershed of a regional
minimum
• Points at which a drop of water will certainly fall
to a single minimum
– Divide lines / Watershed lines
• Points at which a drop of water will be equally
likely to fall to more than one minimum
• Crest lines on the topographic surface
• This technique is to identify all the third type
of points for segmentation
COM 2304 - Computer Graphics & Image
Processing
18
19. Morphological Watersheds (Cont…)
1. Piercing holes in each
regional minimum of I
2. The 3D topography is
flooded from below
gradually
3. When the rising water
in distinct catchment
basins is about to
merge, a dam is built
to prevent the merging
19
COM 2304 - Computer Graphics & Image
Processing
20. 3. The dam boundaries
correspond to the
watershed lines to be
extracted by a watershed
segmentation algorithm
- Eventually only constructed
dams can be seen from
above
Morphological Watersheds (Cont…)
20
COM 2304 - Computer Graphics & Image
Processing
21. Morphological Watersheds (Cont…)
• Dam Construction:
– Based on binary morphological dilation
– At each step of the algorithm, the binary image
in obtained in the following manner
1. Initially, the set of pixels with minimum gray level are
1, others 0.
2. In each subsequent step, we flood the 3D topography
from below and the pixels covered by the rising water
are 1s and others 0s. (See previous slides)
21
COM 2304 - Computer Graphics & Image
Processing
22. Morphological Watersheds (Cont…)
– M1, M2:
• Sets of coordinates of points in the
two regional minima
– Cn-1(M1), Cn-1(M2)
• Sets of coordinates of points in the
catchment basins associated with
M1 M2 at stage n-1 of flooding
(catchment basins up to the
flooding level)
– C[n-1]
• Union of Cn-1(M1), Cn-1(M2)
22
COM 2304 - Computer Graphics & Image
Processing
23. Morphological Watersheds (Cont…)
– At flooding step n-1, there are two
connected components. At flooding
step n, there is only one connected
component
• This indicates that the water
between the two catchment basins
has merged at flooding step n
• Use “q” to denote the single
connected component
– Steps
• Repeatedly dilate Cn-1(M1), Cn-1(M2)
by the 3×3 structuring element
shown, subject to the following
condition
– Constrained to q (center of
the structuring element can
not go beyond q during
dilation)
– The dilation cannot be
performed on point that
would cause the sets being
dilated to merge.
23
COM 2304 - Computer Graphics & Image
Processing
24. Morphological Watersheds (Cont…)
– The dam is constructed by the
points on which the dilation
would cause the sets being
dilated to merge.
• Resulting one-pixel thick
connected path
– Setting the gray level at each
point in the resultant path to a
value greater than the
maximum gray value of the
image. Usually max+1
24
COM 2304 - Computer Graphics & Image
Processing
25. Morphological Watersheds (Cont…)
• The Use of Markers:
– Discussed watershed approach gives
oversegmented result due to noise or any other
irregularities in the image.
– Internal markers are used to limit the number of
regions by specifying the objects of interest
• Like seeds in region growing method
• Can be assigned manually or automatically
• Regions without markers are allowed to be merged (no
dam is to be built)
– External markers those pixels we are confident to
belong to the background
– Watershed lines are typical external markers and
they belong the same (background) region
25
COM 2304 - Computer Graphics & Image
Processing
28. Model Based Segmentation
• Model based approaches apply explicit image
model to locate the specific objects in a
particular image.
• There are various model based segmentation
methods available such as parametric models,
deformable models and template matching.
•
COM 2304 - Computer Graphics & Image
Processing
28
29. Model Based Segmentation (Cont…)
• Template Matching:
– Template matching tries to recognize a structure model
(template) in an image.
– The method uses a template as a context, which is a priori
model.
– Thus, it is a contextual method and top down approach.
– Within the matching process match against the input
image by sliding the template over the input image.
– It uses matching method/ similarity measurement to
locate the matching point.
– http://docs.opencv.org/doc/tutorials/imgproc/histograms/template_matching
/template_matching.html
COM 2304 - Computer Graphics & Image
Processing
29
30. Model Based Segmentation (Cont…)
COM 2304 - Computer Graphics & Image
Processing
30
Template
Matched
template
We used the template matching here to locate the marked template at
consecutive frame and find the motion vector of this angiogram.
Correlation coefficient is used as the similarity measure.
31. Motion Segmentation
• Motion is a powerful cue used by humans and
many other animals to extract objects or ROI
from a background of irrelevant detail.
• In imaging applications, motion arises from a
relative displacement between the sensing
system and the sense being viewed.
• It is used in robotic applications, autonomous
navigation and dynamic scene analysis.
COM 2304 - Computer Graphics & Image
Processing
31
32. Motion Segmentation (Cont…)
• Spatial techniques:
– As a simplest approach we can compute the frame
difference.
– It computes the pixel by pixel difference between two
frames f(x,y,ti) and f(x,y,tj) taken at times ti and tj.
– A difference image between two images taken at ti and tj
may be defined as:
COM 2304 - Computer Graphics & Image
Processing
32
Ttyxftyxfif
otherwiseij
ji
yxd
)|,,(),,(|1
0),(
33. Motion Segmentation (Cont…)
• Note that dij(x,y) has a value of 1 as spatial coordinates (x,
y) only if the intensity difference between two images is
different at those coordinates, as determined by the
specified threshod T.
• In dynamic image processing, all pixels in dij(x,y) with value
1 are considered the result of object motion.
• This approach is applicable only if the two images are
registered spatially and if the illumination is relatively
constant within the bound established by T.
• 1 valued entries in dij(x,y) may arise as a result of noise.
COM 2304 - Computer Graphics & Image
Processing
33
36. Motion Segmentation (Cont…)
– To reduce noise, we can post process the dij(x,y) to remove isolated
noise blobs.
– Although it may result in ignoring small and/or slow moving objects.
• Accumulative differences:
– Consider a sequence of image frames f(x,y,t1), f(x,y,t2), ……, f(x,y,tn)
and let f(x,y,t1) be the reference image.
– An Accumulative Difference Image (ADI) is formed by comparing this
reference image with every subsequent image in the sequence.
– A counter for each pixel location in the accumulative image is
incremented every time a difference occurs at that pixel location
between the reference and an image in the sequence.
•
COM 2304 - Computer Graphics & Image
Processing
36
40. Learning Outcomes Revisit
• Now, you should be able to;
– describe Connected Components and Contours in
image segmentation.
– discuss region based segmentation method.
– discuss Region Growing segmentation technique.
– discuss Morphological Watersheds segmentation.
– discuss Model Based Segmentation.
– discuss Motion Segmentation.
– implement connected components, flood fill,
watershed, template matching and frame difference
techniques.
– formulate possible mechanisms to propose
segmentation methods to solve problems.
COM 2304 - Computer Graphics & Image
Processing
40
41. QUESTIONS ?
Next Lecture – Segmentation Techniques - III
COM 2304 - Computer Graphics & Image
Processing
41