Documente Academic
Documente Profesional
Documente Cultură
WATERSHED
SEGMENTATION
NADINE GARAISY
1
GENERAL DEFINITION
A drainage basin or watershed
is an extent or an area of land
where surface
water from rain melting snow
or ice converges to a single
point at a lower elevation,
usually the exit of the basin,
where the waters join another
waterbody, such as
a river, lake, wetland, sea,
or ocean
2
INTRODUCTION
The Watershed transformation is
a powerful tool for image
segmentation, it uses the region-
based approach and searches for
pixel and region similarities.
3
IMAGE REPRESENTATION
We will represent a gray-tone image by a function:
𝑓: ℤ2 → ℤ
5
IMAGE GRADIENT
6
IMAGE GRADIENT
The morphological gradient of a picture is
defined as
𝑔 𝑓 = 𝑓⨁𝐵 − 𝑓 ⊝ 𝐵
Where 𝑓⨁𝐵 is the dilation of 𝑓 and 𝑓 ⊝ 𝐵 is
its erosion.
But because 𝑓 is continuously differentiable,
𝑔 𝑥 is nothing more than the modulus of the
gradient of 𝑓:
2 2 1/2
𝜕𝑓 𝜕𝑓
𝑔 𝑓 = 𝑔𝑟𝑎𝑑 𝑓 𝑥 = +
𝜕𝑥 𝜕𝑦
7
GEODESIC DISTANCE
For two points 𝑥, 𝑦 𝜖𝑋 when 𝑋 ⊂ ℤ2
we define the geodesic distance
𝑑𝑋 (𝑥, 𝑦) as the length of the shortest
path (if any) included in 𝑋 and linking
𝑥 and 𝑦.
8
GEODESIC ZONE OF
INFLUENCE
𝑔𝑧𝑋 𝑌𝑖 = {𝑥 ∈ 𝑋: 𝑑𝑋 𝑥, 𝑌𝑖 finite
and ∀ 𝑗 ≠ 𝑖, 𝑑𝑋 𝑥, 𝑌𝑖 < 𝑑𝑋 𝑥, 𝑌𝑗 }
9
GEODESIC SKELETON BY ZONES
OF INFLUENCE
The boundaries between
the various zones of
influence give the geodesic
skeleton by Zones of
influence of 𝑌 in 𝑋.
10
MINIMA AND MAXIMA
The set of points in the
function 𝑓 can be seen as
topographic surface 𝑆, The
lighter the gray value of the
function at the point 𝑥 the
higher the altitude of the
corresponding point on the
surface
11
MINIMA AND MAXIMA
An ascending path is a sequence {𝑠1 , 𝑠2 , . . } On the surface
such that:
∀𝑠𝑖 𝑥𝑖 , 𝑓 𝑥𝑖 , 𝑠𝑗 𝑥𝑗 , 𝑓 𝑥𝑗 𝑖 ≥ 𝑗 ⟺ 𝑓 𝑥𝑖 ≥ 𝑓(𝑥𝑗 )
12
ASCENDING PATH
13
NON-ASCENDING PATH
14
THE WATERSHED
TRANSFORMATION
If we look at the image 𝑓 as a topographic surface, imagine
that we pierce each 𝑀𝑖 (𝑓) of the topographic surface 𝑆
and then we plunge this surface into a lake, the water
entering through the holes floods the surface and if two or
more floods coming from different minima attempt to
merge, we avoid this event by building a dam on the
points of the surface where the floods would merge.
15
THE WATERSHED
TRANSFORMATION
16
THE WATERSHED
TRANSFORMATION
http://cmm.ensmp.fr/~beucher/lpe1.gif
17
BUILDING THE WATERSHED
Suppose the flood of the surface has reached the section
𝑍𝑖 (𝑓), when it continue and reach 𝑍𝑖+1 𝑓 the flooding is
18
BUILDING THE WATERSHED
19
BUILDING THE WATERSHED
If we define 𝑊𝑖 𝑓 as the catchment basins of 𝑓 at level 𝑖
and 𝑀𝑖 (𝑓) as the minima of 𝑓 at height 𝑖 + 1 then:
𝑊𝑖+1 𝑓 = 𝐼𝑍𝑍𝑖+1 𝑓 𝑋𝑖 𝑓 ∪ 𝑀𝑖+1 𝑓
20
OVER-SEGMENTATION
PROBLEM
21
OVER-SEGMENTATION:
SOLUTION
The over-segmentation
could be reduced by
appropriate filtering, but
the best results is obtained
by marking the patterns to
be segmented before
preforming the watershed
transformation of the
gradient.
22
OVER-SEGMENTATION:
SOLUTION
23
OVER-SEGMENTATION:
SOLUTION
SECOND: by applying the
watershed on the initial
image we can mark the
background with
connected marker
surrounding the blobs
24
HOMOTOPY MODIFICATION
The first two steps of this
algorithm can be done by
modifying the gradient
function to a new wery similar
function 𝑔′ , the difference
between the two is that in 𝑔′
the initial minima are replaced
by the set 𝑀, this modification
is called homotopy
modification
25
OVER-SEGMENTATION:
SOLUTION
Now we look at the final
result of the marking as a
topographic surface, but in
the flooding process
instead of piercing the
minima, we only make
holes through the
components of the marker
set that we produced
The initial image marked with the
set 𝑀
26
OVER-SEGMENTATION:
SOLUTION
This way the flooding will
produce as many
catchment basins as there
are markers in 𝑀, this way
the watershed lines of the
contours of the objects
will be on the crest lines
of this topographic
surface
27
OVER-SEGMENTATION:
SOLUTION
The algorithm for this solution is as follows:
𝑊𝑖 (𝑔) – section at level 𝑖 of the new catchment basins of 𝑔
Then:
𝑊𝑖+1 (𝑔) = 𝐼𝑍𝑍𝑖+1 ∪𝑀 (𝑊𝑖 𝑔 )
Initialization:
𝑊−1 𝑔 = 𝑀
28
OVERLAPING GRAINS
In some cases we have an
image with overlapping
figures, that we need to
segment, in order to do that
we need to point out the
overlapping regions.
30
REMINDER: DISTANCE
FUNCTION
the distance function of an image assigns for each pixel a
number that is the Euclidean distance between that pixel
and the nearest nonzero pixel.
For example: suppose we have this image matrix-
0 0 0
0 1 0
0 0 1
Then the distance matrix will be-
1.4142 1 1.4142
1 0 1
1.4142 1 0
31
OVERLAPING GRAINS
32
OVERLAPING GRAINS
The markers of the
overlapping regions are
obtained by executing the
watershed transformation
of the inverted distance
function −𝑑 𝑥 , it will
produce divide lines which
will cut the overlapping
grains, that way we can
mark them.
33
OVERLAPING GRAINS
Finally after marking the
background and
calculation the gradient
function we run the
homotopy modification
and the watershed
construction are
preformed
34
THE SEGMENTATION
PARADIGM
The segmentation process is divided into two steps:
I. Finding the markers and
the segmentation.
II. Performing a marker-
controlled watershed
with these two
elements
35
WATERSHED TRANSFOTMATION
PROCESS
Source: A gray scale Step 1: Use the Gradient Step 2: Mark the
image Magnitude as the foreground objects
Segmentation Function -
The gradient is high at
the borders of the objects
and low (mostly) inside
the objects.
FROM - WWW.MATHWORKS.COM 36
WATERSHED TRANSFOTMATION
PROCESS
FROM - WWW.MATHWORKS.COM 37
WATERSHED TRANSFOTMATION
PROCESS
FROM - WWW.MATHWORKS.COM 38
WATERSHED TRANSFOTMATION
PROCESS
FROM - WWW.MATHWORKS.COM 39
WATERSHED TRANSFOTMATION
PROCESS – ADVANCE OPTIONS
FROM - WWW.MATHWORKS.COM 40
ROAD SEGMENTATION
In this study they use the
watershed algorithm among
others to extract vehicle
position on the road and
possible obstacles ahead.
41
ROAD SEGMENTATION
42
ROAD SEGMENTATION
43
ROAD SEGMENTATION
We can enhance the
watershed on the
gradient image by
modifying the gradient
function by defining
new markers which will
be imposed as the new
minima.
44
ROAD SEGMENTATION
46
ROAD SEGMENTATION
47
ROAD SEGMENTATION
Using 𝑀1 and 𝑀2 we
modify the gradient
which now contain
only two minima and
the divide lines are
the contours of the
road
48
ROAD SEGMENTATION
To obtain the road markers we do a
simplification on the image using its
gradient, the result is an image made
of catchment basins tiles of constant
gray values- this image is called the
mosaic-image.
51
LANE BY LANE ROAD
SEGMENTATION
52
POTENTIAL OBSTACLES
DETECTION
The second part of this
study was identifying
obstacles on the road, but
this detection is useless
without a good definition of
the nature of the obstacles,
the problem in this part was
distinguishing a dangerous
obstacle from a light
variation in intensity due,
for instance to a shading. Black marker- the edges of the road
White marker- obstacles-free zone
53
POTENTIAL OBSTACLES
DETECTION
Difficulties in this segmentation:
54
VISUAL EXAMPLES
Illustration of watershed road segmentation:
https://www.youtube.com/watch?v=Tibi6a_aeeE
55
REFERENCES
THE WATERSHED TRANSFORMATION APPLIED TO IMAGE
SEGMENTATION – S.Beucher
ROAD SEGMENTATION BY WATERSHEDS ALGORITHEMS –
S.Beucher, M.Billodeau and X.Yu
USE OF WATERSHEDS IN CONTOUR DETECTION- S.Beucher
and C.Lantuejoul
MATHWORKS.COM
WIKIPEDIA
56
57
TOPOGRAPHIC MAP
58