Digital Image processing
Assoc. Prof. Elham Shawky Salama Omer
Faculty of Computers, and Artificial Intelligence
Cairo University - Egypt.
Image Segmentation
Part-3 “Thresholding and Region
Based Methods ”
2
Image segmentation methods
Image Segmentation
Boundary-Based
(Discontinuity)
(1) Detection of
Discontinuities
Point detection
Line detection
Edge detection
Edge linking and
boundary detection
(2) Local Processing
Global Processing (3) Hough Transform
Region –based
(Similarity)
(5) Thresholding
(6)Region growing
(7) Region splitting
and merge
3
4
Image Segmentation
Thresholding
Light objects in dark background
To extract the objects:
Select a T that separates the objects
from the background
i.e. So: (x,y) belongs:
To object class
if f(x,y)>T
To the background
if f(x,y)≤T
5
Image Segmentation
Thresholding
 A more general case of this approach (multilevel
thresholding)
So: (x,y) belongs:
To First object class
if T1<f(x,y)≤T2
To the other object
if f(x,y)>T2
To the background
if f(x,y)≤T1
• To partition the image histogram by using a single
threshold T.
• Then the image is scanned and labels are assigned.
• This technique is successful in highly controlled
environments.
Image Segmentation
Simple global Thresholding






T
y
x
f
T
y
x
f
y
x
g
)
,
(
if
0
)
,
(
if
1
)
,
(
7
8
9
• Based on the histogram of an image
• Partition the image histogram using a single global threshold
• The success of this technique very strongly depends on how
well the histogram can be partitioned
Image Segmentation
Simple global Thresholding
10
• Imagine a poker playing robot that needs to visually interpret the
cards in its hand
Original Image Thresholded Image
Image Segmentation
Simple global Thresholding
11
• If you get the threshold wrong the results can be disastrous
Threshold Too Low Threshold Too High
Image Segmentation
Simple global Thresholding
12
Thresholding
Optimal Global and Adaptive Thresholding
• This method treats pixel values as probability density functions.
• The goal of this method is to minimize the probability of
misclassifying pixels as either object or background.
• There are two kinds of error:
• mislabeling an object pixel as background, and
• mislabeling a background pixel as object.
13
 Assume the image consists of the objects and background, where
the objects occupy P1 of the pixels (P1+P2=1).
 Assume both objects and background are subject to a Normal
distribution
 By the total probability rule, the image is with the following
density function:
14
 Let T be the threshold. The mis-segmentation takes place
in two cases:
Background pixels miss-classified into object
pixels: the error probability (or the number of errors) is E1
Object pixels miss-classified into background pixels: the
error probability (or the number of errors) is E2
The total mis-segmentation error is
15
If the s.d. are the same and P1=P2=1/2:
If the s.d. are the same:
16
An algorithm used to obtain T automatically for
global thresholding
1. Draw image histogram
2. Compute the average gray level values 1 and 2 for the
pixels in regions G1 and G2.
3. Compute a threshold value: T = ½[1 + 2 ]
4. Compute the binary image g(x,y)






T
y
x
f
T
y
x
f
y
x
g
)
,
(
if
0
)
,
(
if
1
)
,
(
Image Segmentation
Region Based Segmentation
18
• Edges and thresholds sometimes do not give good
results for segmentation.
• Region-based segmentation is based on the
connectivity of similar pixels in a region.
• There are two main approaches to region-based
segmentation: region growing and region splitting.
Image Segmentation
Region Based Segmentation
19
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
R
Ri
n
i


1
(a)
j
i
j
i
R
R j
i 

 ,
and
all
for
(c) 
n
i
Ri ,...,
2
,
1
region,
connected
a
is
(b) 
n
i
R
P i ,...,
2
,
1
for
TRUE
)
(
(d) 

j
i
j
i R
R
R
R
P and
regions
adjacent
any
for
FALSE
)
(
(e) 

20
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.41
Figure 10.40(a)
21
Region-Based Segmentation Region Growing
22
 Problems:
• Starting with a single seed and letting this region grow completely
before trying other seeds basis the segmentation in favor of the
region which are segmented first
• Different choices of seeds may give different segmentation results
• Problems can occur if the (arbitrary chosen) seed points lies on an
edge
Suggested Algorithms and solutions:
• No Single region is allowed to completely dominate the proceedings
• A number of regions are allowed to grow at the same time
Region-Based Segmentation Region Growing
23
Region-Based Segmentation
Region Growing Algorithm
1. Start with a set of seed points and from these grows regions
by appending to each seed point those neighboring pixel that
have similar properties
2. If the absolute difference between the neighbor grey level and
the seed pixel's grey level is less than a threshold ,add this
pixel to the region,
3. Repeat until all pixels are assigned to regions
Designing issues:
Seed selection
Selection of suitable properties for including points in the various
regions (similarity criteria)
24
Region-Based Segmentation Region Growing
25
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.
26
Region-Based Segmentation
Region Splitting
• 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.
27
28
Region-Based Segmentation
Region Merging and Splitting Algorithm
1. Start with the whole image as a single suggested region
2. For each region
1. Compute the variance
2. If
1. then split regions into a set of regions consider these regions as
suggested regions for the next iteration
2. Else, flag the region as a found region R that will not be split any more
Next iteration
Repeated steps until all suggested regions are flagged as regions
After That
There may be more than one region needed to be merged to constitude one
region
2
( )
R T
 
29
Start merging as follow:
1. For each neighbor region R1,R2 Check the following conditions
2. Then merge R1and R2
3. Apply this iteratively
1 1 2 2
2
1 2
| ( ) ( )|
&
( )
R R S
R R T
 

 
 

Lecture 8_Image Segmentation_3_dip__.pdf

  • 1.
    Digital Image processing Assoc.Prof. Elham Shawky Salama Omer Faculty of Computers, and Artificial Intelligence Cairo University - Egypt.
  • 2.
    Image Segmentation Part-3 “Thresholdingand Region Based Methods ” 2
  • 3.
    Image segmentation methods ImageSegmentation Boundary-Based (Discontinuity) (1) Detection of Discontinuities Point detection Line detection Edge detection Edge linking and boundary detection (2) Local Processing Global Processing (3) Hough Transform Region –based (Similarity) (5) Thresholding (6)Region growing (7) Region splitting and merge 3
  • 4.
    4 Image Segmentation Thresholding Light objectsin dark background To extract the objects: Select a T that separates the objects from the background i.e. So: (x,y) belongs: To object class if f(x,y)>T To the background if f(x,y)≤T
  • 5.
    5 Image Segmentation Thresholding  Amore general case of this approach (multilevel thresholding) So: (x,y) belongs: To First object class if T1<f(x,y)≤T2 To the other object if f(x,y)>T2 To the background if f(x,y)≤T1
  • 6.
    • To partitionthe image histogram by using a single threshold T. • Then the image is scanned and labels are assigned. • This technique is successful in highly controlled environments. Image Segmentation Simple global Thresholding       T y x f T y x f y x g ) , ( if 0 ) , ( if 1 ) , (
  • 7.
  • 8.
  • 9.
    9 • Based onthe histogram of an image • Partition the image histogram using a single global threshold • The success of this technique very strongly depends on how well the histogram can be partitioned Image Segmentation Simple global Thresholding
  • 10.
    10 • Imagine apoker playing robot that needs to visually interpret the cards in its hand Original Image Thresholded Image Image Segmentation Simple global Thresholding
  • 11.
    11 • If youget the threshold wrong the results can be disastrous Threshold Too Low Threshold Too High Image Segmentation Simple global Thresholding
  • 12.
    12 Thresholding Optimal Global andAdaptive Thresholding • This method treats pixel values as probability density functions. • The goal of this method is to minimize the probability of misclassifying pixels as either object or background. • There are two kinds of error: • mislabeling an object pixel as background, and • mislabeling a background pixel as object.
  • 13.
    13  Assume theimage consists of the objects and background, where the objects occupy P1 of the pixels (P1+P2=1).  Assume both objects and background are subject to a Normal distribution  By the total probability rule, the image is with the following density function:
  • 14.
    14  Let Tbe the threshold. The mis-segmentation takes place in two cases: Background pixels miss-classified into object pixels: the error probability (or the number of errors) is E1 Object pixels miss-classified into background pixels: the error probability (or the number of errors) is E2 The total mis-segmentation error is
  • 15.
    15 If the s.d.are the same and P1=P2=1/2: If the s.d. are the same:
  • 16.
    16 An algorithm usedto obtain T automatically for global thresholding 1. Draw image histogram 2. Compute the average gray level values 1 and 2 for the pixels in regions G1 and G2. 3. Compute a threshold value: T = ½[1 + 2 ] 4. Compute the binary image g(x,y)       T y x f T y x f y x g ) , ( if 0 ) , ( if 1 ) , (
  • 17.
  • 18.
    18 • Edges andthresholds sometimes do not give good results for segmentation. • Region-based segmentation is based on the connectivity of similar pixels in a region. • There are two main approaches to region-based segmentation: region growing and region splitting. Image Segmentation Region Based Segmentation
  • 19.
    19 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 R Ri n i   1 (a) j i j i R R j i    , and all for (c)  n i Ri ,..., 2 , 1 region, connected a is (b)  n i R P i ,..., 2 , 1 for TRUE ) ( (d)   j i j i R R R R P and regions adjacent any for FALSE ) ( (e)  
  • 20.
    20 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.41 Figure 10.40(a)
  • 21.
  • 22.
    22  Problems: • Startingwith a single seed and letting this region grow completely before trying other seeds basis the segmentation in favor of the region which are segmented first • Different choices of seeds may give different segmentation results • Problems can occur if the (arbitrary chosen) seed points lies on an edge Suggested Algorithms and solutions: • No Single region is allowed to completely dominate the proceedings • A number of regions are allowed to grow at the same time Region-Based Segmentation Region Growing
  • 23.
    23 Region-Based Segmentation Region GrowingAlgorithm 1. Start with a set of seed points and from these grows regions by appending to each seed point those neighboring pixel that have similar properties 2. If the absolute difference between the neighbor grey level and the seed pixel's grey level is less than a threshold ,add this pixel to the region, 3. Repeat until all pixels are assigned to regions Designing issues: Seed selection Selection of suitable properties for including points in the various regions (similarity criteria)
  • 24.
  • 25.
    25 Region-Based Segmentation Region Splittingand 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.
  • 26.
    26 Region-Based Segmentation Region Splitting •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.
  • 27.
  • 28.
    28 Region-Based Segmentation Region Mergingand Splitting Algorithm 1. Start with the whole image as a single suggested region 2. For each region 1. Compute the variance 2. If 1. then split regions into a set of regions consider these regions as suggested regions for the next iteration 2. Else, flag the region as a found region R that will not be split any more Next iteration Repeated steps until all suggested regions are flagged as regions After That There may be more than one region needed to be merged to constitude one region 2 ( ) R T  
  • 29.
    29 Start merging asfollow: 1. For each neighbor region R1,R2 Check the following conditions 2. Then merge R1and R2 3. Apply this iteratively 1 1 2 2 2 1 2 | ( ) ( )| & ( ) R R S R R T       