part 7: image segmentation -...

36
2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning Systems Lab, Dep. Teknik Room T1209 [email protected] Part 7: Image Segmentation Course Book Chapter 10

Upload: others

Post on 31-Jul-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

2010-05-12

Digital Image Processing

Achim J. Lilienthal

AASS Learning Systems Lab, Dep. Teknik

Room T1209

[email protected]

Part 7: Image Segmentation

Course Book Chapter 10

Page 2: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Contents

1. Image Segmentation

2. Edge Detection

z Edge Model

z Edge Detectors

z Prewitt, Sobel, Laplacian of a Gaussian

z Canny Edge Detector

z Edge Detection in Colour Images

3. Edge Linking and Boundary Detection

4. Thresholding

Page 3: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Contents

5. Colour Segmentation

6. Region-Based Segmentation

7. Watershed Segmentation

8. Motion-Based Segmentation

Page 4: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Image Segmentation

Contents

Page 5: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Image Segmentation

z Segmentation

y full segmentation

x individual objects are separated from the background

and given individual ID numbers (labels)

y partial segmentation

x the amount of data is reduced (usually by separating objects

from background) to speed up the further processing

! segmentation is often the most difficult problem

to solve in the process; there is no universal solution!

! the problem can be made much easier if solved

in cooperation with the constructor of the imaging system

(choice of sensors, illumination, background etc.)

1

Page 6: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Image Segmentation

z Approaches to Segmentation

y edge-based

x search for edges in the image

x edges can be linked to obtain borders between regions

y region-based

x search for consistent regions

x thresholding, classification, region growing/splitting & merging, …

y motion-based

x separate moving foreground objects from background model

z Common Idea

y search for discontinuities and/or similarities in the image

1

Page 7: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

Contents

Page 8: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Discontinuities

y points, lines, edges

y edge detection is the most common approach

used for image segmentation

z Edge Detection

2

edge detection

Page 9: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Edge Detection

y edge is a "local" concept

y should ideally correspond

to a region boundary

("global" concept)

y ideally pixels at an

orthogonal step transition

z Edge Model

y strong change of intensity (colour)

= steep regions in a relief map (3D)

2

Page 10: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Edge Model

y magnitude of the

first derivative to detect

the presence of an edge

x edge point if 1st derivative

is greater than a threshold

y second derivative shows

two peaks

x connection of the

peaks crosses near

the edge midpoint

x edge = zero crossing

of the 2nd derivative

2

zero-crossing

Page 11: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Edge Detection – Morphology

y simple edge detector for binary images

(top-hat transformation)

2

fbfh )(

Page 12: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Edge Detection in Grey Level Images

y remove noise

x necessary because the first and

the second derivative are very

sensitive to image noise

2

Page 13: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Edge Detection in Grey Level Images

y remove noise

x mean, Gaussian, median filter, ...

x dilemma

• large filter

removes noise but also edges

• small filter

keeps edges but not

effcient in removing noise

y edge detection/enhancement

x 1st or 2nd derivative, apply threshold

y edge localisation

2

Page 14: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Edge Detectors

y Prewitt and Sobel

x 2 masks approximate | Gx | and | Gy | in

y Prewitt

2

yx GGy

f

x

ff

10-1

10-1

10-1

-1-1-1

000

111

Page 15: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Edge Detectors

y Prewitt and Sobel

x 2 masks approximate | Gx | and | Gy | in

y Sobel

2

yx GGy

f

x

ff

10-1

20-2

10-1

-1-2-1

000

121

Page 16: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Sobel Edge Detector

2

Sobel

Sobel

Page 17: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Edge Detectors

y Laplacian

x approximation to

2

2

2

2

22

y

f

x

f

010

1-41

010111

1-81

111

Page 18: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Edge Detectors

y Laplacian of a Gaussian (LoG)

x Gaussian used for smoothing

x combined with the Laplacian 2nd derivative of the Gaussian

x "mexican hat" function

2

2

2

24

222

r

er

rh

Page 19: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Laplacian of a Gaussian (LoG) Edge Detector

2

LoG

Page 20: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Laplacian of a Gaussian (LoG) Edge Detector

y LoG implemented as two different masks

x masks are typically smaller

y plain determination of the zero-crossings

2

LoG zero-crossingsbinary imageoriginal image

Page 21: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Laplacian of a Gaussian (LoG) Edge Detector

y Gauss filter width:

x 5x5 pixels

x 9x9 pixels

x 12x12 pixels

2

Page 22: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Canny Edge Detector – Gradient Estimation

1. noise reduction

y 2D Gaussian kernel used for smoothing

2. edge detection/enhancement

y 2-D first derivative operator

y for example: Sobel operator

y edges in the image cause

ridges in the gradient image

2

yx GGy

f

x

ff

Page 23: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Edge Detectors

y Prewitt and Sobel

x 2 masks approximate | Gx | and | Gy | in

y Sobel

2

yx GGy

f

x

ff

10-1

20-2

10-1

1-2-1

000

121

Page 24: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Canny Edge Detector – Gradient Estimation

1. noise reduction

y 2D Gaussian kernel used for smoothing

2. edge detection/enhancement

y 2-D first derivative operator

y for example: Sobel operator

y edges in the image cause

ridges in the gradient image

3. determine the intensity gradient

y can be calculated from Gx and Gy

y alternatively using more filter masks to

detect horizontal, vertical, diagonal edges, ...

2

yx GGy

f

x

ff

x

y

G

G1tan

Page 25: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Canny Edge Detector – Non-Maximum Suppression

4. non-maximum suppression (thinning of edges)

y delete all but the local maximum of edge intensity

y implementation:

• identify the 4 closest pixels perpendicular

to the edge direction = A, B, C, D

• estimate gradient next to the origin O

along the gradient direction by

linear interpolation between A and B P,

linear interpolation between C and D Q

• set O to zero if the magnitude of the

gradient is not higher than the magnitude

of the gradient at P and Q (non-maximum)

2

A B

C D

P

Q

Page 26: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Canny Edge Detector – Hysteresis Thresholding

5. tracing edges through the image

y higher intensity gradients are more likely to be edges

y pixels with a low |gradient| connected to pixels with high |gradient|

are likely to be edges (trace faint sections of edges)

y implementation: thresholding with hysteresis

• two thresholds Thigh and Tlow

• set all pixels below Tlow to zero

• mark edges above Thigh

• trace through the image (using the gradient information)

following the edges applying the lower threshold Tlow

• discard short connected edge sections

y allows to trace faint sections of lines if there is a starting point

2

Page 27: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Canny Edge Detector – Parameter Selection

y size of the Gaussian filter

x smaller filter less blurring, allows for detection of smaller edges

x larger filter for detection of larger, smoother edges

y hysteresis thresholds

x Thigh high enough so that most noise edges are eliminated

x Tlow high enough so that pixels > Tlow are still meaningful edge pixels

• express Thigh and Tlow as absolute magnitudes

• express Thigh and Tlow as fractions of the maximum gradient

magnitude in the image

2

Page 28: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Canny Edge Detector – Parameter Selection

2

Gauss 5x5,

Thigh = 255,

Tlow = 1

Gauss 5x5,

Thigh = 255,

Tlow = 220

Gauss 5x5,

Thigh = 128,

Tlow = 1

Gauss 9x9,

Thigh = 128,

Tlow = 1

Page 29: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Canny Edge Detector – Parameter Selection

2

= 1, Thigh = 0.5, Tlow = 0.05

no non-maximum suppressionfrom http://matlabserver.cs.rug.nl

Page 30: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Canny Edge Detector – Parameter Selection

2

= 5, Thigh = 0.5, Tlow = 0.05

no non-maximum suppressionfrom http://matlabserver.cs.rug.nl

Page 31: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Canny Edge Detector – Parameter Selection

2

= 1, Thigh = 0.5, Tlow = 0.05,

non-maximum suppressionfrom http://matlabserver.cs.rug.nl

Page 32: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Canny Edge Detector – Parameter Selection

2

= 5, Thigh = 0.5, Tlow = 0.05,

non-maximum suppressionfrom http://matlabserver.cs.rug.nl

Page 33: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Canny Edge Detector – Parameter Selection

2

= 20, Thigh = 0.5, Tlow = 0.05,

non-maximum suppressionfrom http://matlabserver.cs.rug.nl

Page 34: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Canny Edge Detector – Parameter Selection

2

= 5, Thigh = 0.3, Tlow = 0.05,

non-maximum suppressionfrom http://matlabserver.cs.rug.nl

Page 35: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Canny Edge Detector – Parameter Selection

2

= 2, Thigh = 0.2, Tlow = 0.1,

non-maximum suppressionfrom http://matlabserver.cs.rug.nl

Page 36: Part 7: Image Segmentation - 130.243.105.49130.243.105.49/Research/Learning/courses/dip/.../lectures/DIP_2011… · 2010-05-12 Digital Image Processing Achim J. Lilienthal AASS Learning

Achim J. Lilienthal

Edge Detection

z Canny Edge Detector – Examples

2

Gauss 5x5,

Thigh = 200,

Tlow = 1

Gauss 7x7,

Thigh = 200,

Tlow = 1

from http://www.cee.hw.ac.uk/hipr/html/canny.html