0% found this document useful (0 votes)
8 views

Lecture 7 Segmentation

Uploaded by

joss man
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Lecture 7 Segmentation

Uploaded by

joss man
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

CSE 511: Digital Image Processing

Chapter: 10
Image Segmentation:
Thresholding
2
of
20
Contents
So far we have been considering image
processing techniques used to transform
images for human interpretation
Today we will begin looking at automated
image analysis by examining the thorny issue
of image segmentation:
– The segmentation problem
– Finding points, lines and edges
3
of
20
The Segmentation Problem
Segmentation attempts to partition the pixels
of an image into groups that strongly
correlate with the objects in an image
Typically the first step in any automated
computer vision application
The Segmentation Problem-2

Segmentation algo based on 2 basic


categories dealing with intensity values:

Discontinuity:
- We assume that boundaries of
regions are different from each-other
- e.g. Edge-based segmentation

Similarity:
- Partitioning into regions that are
similar to each-other
- e.g. Region-based segmentation
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
4
of
20
Segmentation Examples
5
of
20
Detection Of Discontinuities
There are three basic types of grey level
discontinuities that we tend to look for in
digital images:
– Points
– Lines
– Edges
We typically find discontinuities using masks
and correlation
6
of
20
Point Detection
Point detection can be achieved simply
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

using the mask(Laplacian) below:

Points are detected at those pixels in the


subsequent filtered image that are above a
set threshold
Point Detection
-
- We can use Laplacian masks
for point detection. -¿„ 8 —
1
- l yl -1
- Laplacian masks have the larges
coefficient at the center of the
mask while neighbor pixels have an
opposite sign.

-This mask will give the high response to the object that has the
similar shape as the mask such as isolated points.

-Notice that sum of all coefficients o1 the mask is equal to zero.


This is due to the need that the response of the filter must be zero
inside a constant intensity area
7
of
20
Point Detection (cont…)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

X-ray image of Result of point Result of


a turbine blade detection thresholding
8
of
20
Line Detection
The next level of complexity is to try to
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

detect lines
The masks below will extract lines that are
one pixel thick and running in a particular
direction
9
of
20
Line Detection (cont…)
Binary image of a wire
bond mask
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

After
Result of
processing
thresholding
with -45° line
filtering result
detector
10
of
20
Edge Detection
An edge is a set of connected pixels that lie
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

on the boundary between two regions


11
of
20
Edges & Derivatives
We have already spoken
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

about how derivatives


are used to find
discontinuities
1st derivative tells us
where an edge is
2nd derivative can
be used to show
edge direction
12
of
20
Derivatives & Noise
Derivative based edge detectors are
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

extremely sensitive to noise


We need to keep this in mind
13
of
20
Common Edge Detectors
Given a 3*3 region of an image the following
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

edge detection filters can be used


14
of
20
Edge Detection Example
Original Image Horizontal Gradient Component
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Vertical Gradient Component Combined Edge Image


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

of
15

20
Edge Detection Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

of
16

20
Edge Detection Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

of
17

20
Edge Detection Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

of
18

20
Edge Detection Example
19
of
20
Edge Detection Problems
Often, problems arise in edge detection in
that there are too much detail
For example, the brickwork in the previous
example
One way to overcome this is to smooth
images prior to edge detection
20
of
Edge Detection Example With
20 Smoothing
Original Image Horizontal Gradient Component
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Vertical Gradient Component Combined Edge Image


21
of
20
Laplacian Edge Detection
We encountered the 2nd-order derivative
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

based Laplacian filter already

The Laplacian is typically not used by itself


as it is too sensitive to noise
Usually for edge detection the Laplacian is
combined with a smoothing Gaussian filter
22
of
20
Laplacian Of Gaussian
The Laplacian of Gaussian (or Mexican hat)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

filter uses the Gaussian for noise removal


and the Laplacian for edge detection
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

of
23

20
Laplacian Of Gaussian Example
24
of
20
Summary
In this lecture we have begun looking at
segmentation, and in particular edge detection
Edge detection is massively important as it is
in many cases the first step to object
recognition
25
of
20
Contents
Today we will continue to look at the problem
of segmentation, this time though in terms
of thresholding
In particular we will look at:
– What is thresholding?
– Simple thresholding
– Adaptive thresholding
26
of
20
Thresholding
Thresholding is usually the first step in any
segmentation approach
We have talked about simple single value
thresholding already
Single value thresholding can be given
mathematically as follows:
1if f (x, y)  T
g(x, y)  
0 if f (x, y)  T
27
of
20
Thresholding Example
Imagine a poker playing robot that needs to
visually interpret the cards in its hand

Original Image Thresholded Image


28
of
20
But Be Careful
If you get the threshold wrong the results
can be disastrous

Threshold Too Low Threshold Too High


29
of
20
Basic Global Thresholding
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
30
of
20
Basic Global Thresholding Algorithm
The basic global threshold, T, is calculated
as follows:
1. Select an initial estimate for T (typically the
average grey level in the image)
2. Segment the image using T to produce two
groups of pixels: G1 consisting of pixels
with grey levels >T and G2 consisting
pixels with grey levels ≤ T
3. Compute the average grey levels of pixels
in G1 to give μ1 and G2 to give μ2
31
of
20
Basic Global Thresholding Algorithm
4. Compute a new threshold value:
1  2
T
2
5. Repeat steps 2 – 4 until the difference in T
in successive iterations is less than a
predefined limit T ∞
This algorithm works very well for finding
thresholds when the histogram is suitable
- Find out thr for: 5 3 9 2 1 7 8 4 2
Evaluating the threshold value

Find out thresholding for: 5 3 9 2 1 7 8 4 2


1) Find the avg, 𝑇0 = (5+3+9+2+1+7+8+4+2)/8 = 5.125 = 5(Rounding up)
2) G1 = {5,3,9,2,1}, G2 ={7,8,4,2}
5+3+9+2+1 7+8+4+2
3) 𝑎𝑣𝑔𝑔1 = 5
= 4 , 𝑎𝑣𝑔𝑔2 =
4
= 5.25
4) 𝑇1 = (4+5.25)/2 = 4.625 = 5(Rounding up)
5) 𝑇1 − 𝑇0 < 𝑙𝑖𝑚𝑖𝑡; 𝑒𝑙𝑠𝑒 𝑟𝑒𝑝𝑒𝑎𝑡 (2 − 4)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

of
32

20
Thresholding Example 1
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

of
33

20
Thresholding Example 2
34
of
Problems With Single Value
20 Thresholding
Single value thresholding only works for
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

bimodal histograms
Images with other kinds of histograms need
more than a single threshold
35
of
Problems With Single Value
20 Thresholding (cont…)
Let’s say we want to
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

isolate the contents


of the bottles
Think about what the
histogram for this
image would look like
What would happen if we used a single
threshold value?
36
of
Single Value Thresholding and
20 Illumination
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Uneven illumination can really upset a single


valued thresholding scheme
37
of
20
Basic Adaptive Thresholding
An approach to handling situations in which
single value thresholding will not work is to
divide an image into sub images and
threshold these individually
Since the threshold for each pixel depends
on its location within an image this
technique is said to adaptive
38
of
20
Basic Adaptive Thresholding Example

The image below shows an example of using


adaptive thresholding with the image shown
previously

As can be seen success is mixed


But, we can further subdivide the troublesome
sub images for more success
39
of
Basic Adaptive Thresholding Example
20 (cont…)
These images show the
troublesome parts of the
previous problem further
subdivided
After this sub division
successful thresholding
can be
achieved
40
of
20
Summary
In this lecture we have begun looking at
segmentation, and in particular thresholding
We saw the basic global thresholding algorithm
and its shortcomings
We also saw a simple way to overcome some
of these limitations using adaptive
thresholding

You might also like