Top Banner
Digital Image Processing, 2nd ed. www.imageprocessingbook.com 002 R. C. Gonzalez & R. E. Woods Chapter 10 Image Segmentation
51
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Chapter 10Image Segmentation

Chapter 10Image Segmentation

Page 2: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Chapter 10Image Segmentation

Chapter 10Image Segmentation

• Image segmentation divides an image into regions that are connected and have some similarity within the region and some difference between adjacent regions.

• The goal is usually to find individual objects in an image.• For the most part there are fundamentally two kinds of

approaches to segmentation: discontinuity and similarity. – Similarity may be due to pixel intensity, color or texture. – Differences are sudden changes (discontinuities) in any of these, but

especially sudden changes in intensity along a boundary line, which is called an edge.

Page 3: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Detection of DiscontinuitiesDetection 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

1992211 ...

iii zwzwzwzwR

Page 4: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Detection of DiscontinuitiesPoint Detection

Detection of DiscontinuitiesPoint Detection

thresholdenonnegativ a: where T

TR

Page 5: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Detection of DiscontinuitiesLine Detection

Detection of DiscontinuitiesLine Detection

• Only slightly more common than point detection is to find a one pixel wide line in an image.

• For digital images the only three point straight lines are only horizontal, vertical, or diagonal (+ or –45).

Page 6: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Detection of DiscontinuitiesLine Detection

Detection of DiscontinuitiesLine Detection

Page 7: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Detection of DiscontinuitiesEdge Detection

Detection of DiscontinuitiesEdge Detection

Page 8: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Detection of DiscontinuitiesEdge Detection

Detection of DiscontinuitiesEdge Detection

Page 9: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Detection of DiscontinuitiesEdge Detection

Detection of DiscontinuitiesEdge Detection

Page 10: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Detection of DiscontinuitiesEdge Detection

Detection of DiscontinuitiesEdge Detection

Page 11: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Detection of DiscontinuitiesGradient Operators

Detection of DiscontinuitiesGradient Operators

• First-order derivatives:– The gradient of an image f(x,y) at location (x,y) is defined

as the vector:

– The magnitude of this vector:

– The direction of this vector:

yfxf

y

x

G

Gf

21

22)(mag yx GGf f

y

x

G

Gyx 1tan),(

Page 12: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Detection of DiscontinuitiesGradient Operators

Detection of DiscontinuitiesGradient Operators

Roberts cross-gradient operators

Prewitt operators

Sobel operators

Page 13: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Detection of DiscontinuitiesGradient Operators

Detection of DiscontinuitiesGradient Operators

Prewitt masks for detecting diagonal edges

Sobel masks for detecting diagonal edges

Page 14: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

yx GGf

Detection of DiscontinuitiesGradient Operators: ExampleDetection of Discontinuities

Gradient Operators: Example

Page 15: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Detection of DiscontinuitiesGradient Operators: ExampleDetection of Discontinuities

Gradient Operators: Example

Page 16: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Detection of DiscontinuitiesGradient Operators: ExampleDetection of Discontinuities

Gradient Operators: Example

Page 17: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Detection of DiscontinuitiesGradient Operators

Detection of DiscontinuitiesGradient Operators

• Second-order derivatives: (The Laplacian)– The Laplacian of an 2D function f(x,y) is defined as

– Two forms in practice:

2

2

2

22

y

f

x

ff

Page 18: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Detection of DiscontinuitiesGradient Operators

Detection of DiscontinuitiesGradient Operators

• Consider the function:

• The Laplacian of h is

• 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.

deviation standard the: and

where)( 2222 2

2

yxrerhr

2

2

24

222 )(

r

er

rh

The Laplacian of a Gaussian (LoG)

A Gaussian function

Page 19: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Detection of DiscontinuitiesGradient Operators

Detection of DiscontinuitiesGradient Operators

Page 20: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Detection of DiscontinuitiesGradient Operators: ExampleDetection of Discontinuities

Gradient Operators: Example

Sobel gradient

Laplacian maskGaussian smooth function

Page 21: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Detection of DiscontinuitiesGradient Operators: ExampleDetection of Discontinuities

Gradient Operators: Example

Page 22: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Edge Linking and Boundary DetectionLocal Processing

Edge Linking and Boundary DetectionLocal 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

thresholdenonnegativ a: ,),(),( 00 EEyxyxf

thresholdangle nonegative a: ,),(),( 00 AAyxyx

Page 23: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Edge Linking and Boundary DetectionLocal Processing: Example

Edge Linking and Boundary DetectionLocal Processing: Example

In this example,we can find thelicense plate candidate afteredge linkingprocess.

Page 24: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Edge Linking and Boundary DetectionGlobal Processing via the Hough Transform

Edge Linking and Boundary DetectionGlobal Processing via the Hough Transform

• Hough transform: a way of finding edge points in an image that lie along a straight line.

• Example: xy-plane v.s. ab-plane (parameter space)

baxy ii

Page 25: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Edge Linking and Boundary DetectionGlobal Processing via the Hough Transform

Edge Linking and Boundary DetectionGlobal Processing via the Hough Transform

• The Hough transform consists of finding all pairs of values of and which satisfy the equations that pass through (x,y).

• These are accumulated in what is basically a 2-dimensional histogram.

• When plotted these pairs of and will look like a sine wave. The process is repeated for all appropriate (x,y) locations.

sincos yx

Page 26: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Edge Linking and Boundary DetectionHough Transform Example

Edge Linking and Boundary DetectionHough Transform Example

The intersection of the curves corresponding

to points 1,3,5

2,3,4

1,4

Page 27: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Edge Linking and Boundary DetectionHough Transform Example

Edge Linking and Boundary DetectionHough Transform Example

Page 28: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

ThresholdingThresholding

• Assumption: the range of intensity levels covered by objects of interest is different from the background.

Single threshold Multiple threshold

Tyxf

Tyxfyxg

),( if 0

),( if 1),(

Page 29: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

ThresholdingThe Role of Illumination

ThresholdingThe Role of Illumination

Page 30: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

ThresholdingThe Role of Illumination

ThresholdingThe Role of Illumination

(a) (c)

(e)(d)

),(),(),( yxryxiyxf

),( yxi),( yxr

Page 31: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

ThresholdingBasic Global Thresholding

ThresholdingBasic Global Thresholding

Page 32: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

ThresholdingBasic Global Thresholding

ThresholdingBasic Global Thresholding

Page 33: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

ThresholdingBasic Adaptive Thresholding

ThresholdingBasic Adaptive Thresholding

Page 34: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

ThresholdingBasic Adaptive Thresholding

ThresholdingBasic Adaptive Thresholding

How to solve this problem?

Page 35: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

ThresholdingBasic Adaptive Thresholding

ThresholdingBasic Adaptive Thresholding

Answer: subdivision

Page 36: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

ThresholdingOptimal Global and Adaptive Thresholding

ThresholdingOptimal 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.

Page 37: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

ThresholdingUse of Boundary Characteristics

ThresholdingUse of Boundary Characteristics

Page 38: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

ThresholdingThresholds Based on Several Variables

ThresholdingThresholds Based on Several Variables

Color image

Page 39: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Region-Based SegmentationRegion-Based Segmentation

• 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.– Each region must be uniform.

– Connectivity of the pixels within the region is very important.

• There are two main approaches to region-based segmentation: region growing and region splitting.

Page 40: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Region-Based SegmentationBasic Formulation

Region-Based SegmentationBasic Formulation

• Let R represent the entire image region.

• Segmentation is a process that partitions R into subregions, R1,R2,…,Rn, such that

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.

RRi

n

i

1 (a)

jijiRR ji , and allfor (c) niRi ,...,2,1 region, connected a is (b)

niRP i ,...,2,1for TRUE)( (d)

jiji RRRRP and regionsadjacent any for FALSE)( (e)

Page 41: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Region-Based SegmentationRegion Growing

Region-Based SegmentationRegion Growing

Page 42: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Region-Based SegmentationRegion Growing

Region-Based SegmentationRegion 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.41Figure 10.40(a)

Page 43: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Region-Based SegmentationRegion Splitting and MergingRegion-Based SegmentationRegion 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.

Page 44: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Region-Based SegmentationRegion Splitting

Region-Based SegmentationRegion 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.

Page 45: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Region-Based SegmentationRegion Splitting and MergingRegion-Based SegmentationRegion 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.

Page 46: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Segmentation by Morphological WatershedsSegmentation by Morphological Watersheds

• The concept of watersheds is based on visualizing an image in three dimensions: two spatial coordinates versus gray levels.

• In such a topographic interpretation, we consider three types of points:

– (a) points belonging to a regional minimum

– (b) points at which a drop of water would fall with certainty to a single minimum

– (c) points at which water would be equally likely to fall to more than one such minimum

• The principal objective of segmentation algorithms based on these concepts is to find the watershed lines.

Page 47: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Segmentation by Morphological WatershedsExample

Segmentation by Morphological WatershedsExample

Page 48: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Segmentation by Morphological WatershedsExample

Segmentation by Morphological WatershedsExample

Page 49: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

Segmentation by Morphological WatershedsExample

Segmentation by Morphological WatershedsExample

Page 50: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

The Use of Motion in SegmentationThe Use of Motion in Segmentation

• ADI: accumulative difference image

Page 51: Chapter 10

Digital Image Processing, 2nd ed.Digital Image Processing, 2nd ed.www.imageprocessingbook.com

© 2002 R. C. Gonzalez & R. E. Woods

The Use of Motion in SegmentationThe Use of Motion in Segmentation