102
Faculty Orientation Workshop on BE (E&TC/Elex) Revised Syllabus 2015 Course Under the aegis of BoS-E&TC, SPPU, Pune Unit 4: Image Segmentation Digital Image And Video Processing (Elective-I) Dr. Ashwini M. Deshpande Cummins College of Engineering for Women Dept. of E&Tc Engg.

Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

Faculty Orientation Workshop on BE (E&TC/Elex) Revised Syllabus 2015 Course

Under the aegis of BoS-E&TC, SPPU, Pune

Unit 4: Image Segmentation

Digital Image And Video Processing (Elective-I)

Dr. Ashwini M. Deshpande

Cummins College of Engineering for Women

Dept. of E&Tc Engg.

Page 2: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

2

Topics to be covered Topic to be referred

from

Pixel classification, Bi-level thresholding, Multi-level

thresholding, Adaptive thresholding, Otsu’s method

Sec. 10.3

Edge detection-

First order derivative- Prewitt and Sobel,

Second order derivative- LoG, DoG,

Canny

Sec. 10.1

Edge linking, Hough Transform Sec. 10.2

Region growing, Region splitting and merging Sec. 10.4

Morphological operators- Dilation, Erosion, Opening,

Closing, Hit or Miss transform, Boundary extraction

Sec. 9.2, 9.3, 9.4, 9.5.1

Thinning, Thickening, Skeletons Sec. 9.5.5, 9.5.6, 9.5.7

T1. Gonzalez and Woods, "Digital Image Processing", Pearson Education,

(3rd Edition)

Contents (8 Hrs)

Page 3: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

33

Introduction

◼ Segmentation is to to partition an image intoits constituent regions or objects that stronglycorrelate

◼ Important step in automatic pictorial patternrecognition and scene analysis

Page 4: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

4

Segmentation Examples

Page 5: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

55

Principal approaches

◼ Segmentation algorithms generally are based onone of 2 basic properties of intensity values-◼ Discontinuity : to partition an image based on sharp

changes in intensity

◼ Similarity : to partition an image into regions that are similar according to a set of predefined criteria

Page 6: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

66

Detection of Discontinuities

◼ To detect the three basic types of gray-level discontinuities◼ points, lines, edges

◼ The common way is to run a mask through the image

=

=+++=9

1

992211 ...i

ii zwzwzwzwR

Page 7: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

77

Point Detection

◼ Point (isolated) detection can be achieved simply using the mask above

◼ A point can be detected at the location on which the mask is centered. If, |R| T

◼ where ◼ T is a nonnegative threshold ◼ R is the sum of products of the coefficients with the gray

levels contained in the region encompassed by the mark.

❑ Points are detected at those pixels in the subsequent filtered image that are above a set threshold

Page 8: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

8

Point Detection

X-ray image of

a turbine blade

Result of point

detection

Result of

thresholding

Page 9: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

99

Line Detection

◼ Horizontal mask will result with max response when a line passed through the middle row of the mask with a constant background. Similar idea is used with other masks.

Page 10: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

1010

Line Detection

◼ Apply every mask on the image◼ Let R1, R2, R3, R4 denotes the response of

the horizontal, +45 degree, vertical and-45 degree masks, respectively.

◼ If, at a certain point in the image|Ri| > |Rj|,

◼ For all ji, that point is said to be morelikely associated with a line in thedirection of mask i.

Page 11: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

1111

Example

Binary image of a

wire bond mask

After

processing

with -45°line

detector

Result of

thresholding

filtering result

• Figures from Gonzalez

Page 12: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

1212

Edge Detection

◼ An edge is a set of connected pixelsthat lie on the boundary between tworegions◼ first-order derivative (Gradient

operator)

◼ second-order derivative (Laplacianoperator)

Page 13: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

13

Characterizing edges

◼ An edge is a place of rapid change inthe image intensity function

imageintensity function

(along horizontal scanline) first derivative

edges correspond to

extrema of derivative

Page 14: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

1414

Ideal and Ramp Edges

Page 15: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

Derivatives of 1-D Digital Functions

15© 1992-2008 R.C. Gonzalez & R.E. Woods

Page 16: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

1616

First and Second derivatives

the signs of the derivatives would be reversed for an edge that transitions from light to dark

Page 17: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

1717

Second derivatives

◼ Produces 2 values for every edge in animage (an undesirable feature)

◼ An imaginary straight line joining theextreme positive and negative values ofthe second derivative would cross zeronear the midpoint of the edge. (zero-crossing property)

◼ Useful for locating the centers of thickedges

Page 18: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

1818

Gradient Operator

◼ first derivatives are implemented using the magnitude of the gradient.

=

=

y

fx

f

G

G

y

xf

21

22

21

22 ][)f(

+

=

+==

y

f

x

f

GGmagf yx

yx GGf +

commonly approx.

Page 19: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

19

◼ The direction of this gradient:

**correction (Gy/Gx)

= −

y

x

G

Gyx 1tan),(

Gradient Operator

Page 20: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

Gradient and Edge

20© 1992-2008 R.C. Gonzalez & R.E. Woods

Page 21: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

21

Roberts cross-gradient operators

Prewitt operators

Sobel operators

Gradient Masks

Page 22: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

2222

Diagonal edges with Prewitt and Sobel masks

Page 23: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

2323

Example

Page 24: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

2424

Example

Page 25: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

2525

Example

Page 26: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

2626

Second Order Derivative Methods - Laplacian

2

2

2

22 ),(),(

y

yxf

x

yxff

+

=(linear operator)

Laplacian operator

)],(4)1,()1,(

),1(),1([2

yxfyxfyxf

yxfyxff

−−+++

−++=

Page 27: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

2727

Laplacian of Gaussian (LoG)

◼ Laplacian combined with smoothing to find edges via zero-crossing.

2

2

2)(

r

erh−

−=

where r2 = x2+y2, and is the standard deviation

2

2

24

222 )(

r

er

rh−

−−=

Page 28: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

2828

Mexican hat

Page 29: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

2929

Example

a). Original imageb). Sobel Gradientc). Spatial Gaussian smoothing functiond). Laplacian maske). LoGf). Threshold LoGg). Zero crossing

Page 30: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

30

Second Order Derivative Methods -Difference of Gaussian - DoG

◼ LoG requires large computation time for a large edge detector mask

◼ To reduce computational requirements, approximate the LoG by the difference of two LoG – the DoG

2

2

)2

22(

2

1

)2

22(

22),(

22

21

yxyx

eeyxDoG

+−

+−

−=

Page 31: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

31

Canny Edge Detector

Original image

Smoothing by Gaussian convolution

Differential operators along x and y axis

Non-maximum suppressionfinds peaks in the image gradient

Hysteresis thresholding locates edge strings

Edge map

Page 33: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

33

➢Approaches:-Thresholding

- Region growing technique

- Region splitting and merging technique

Similarity based image Segmentation

Page 34: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

34

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:

=

Tyxfif

Tyxfifyxg

),( 0

),( 1),(

Page 35: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

3535

Thresholdingimage with dark background and a light object

image with dark background and two light objects

Page 36: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

36

Problems With Single Value Thresholding

◼Single value thresholding only works forbimodal histograms

◼Images with other kinds of histogramsneed more than a single threshold

Multi-level thresholding

Bi-level thresholding

Page 37: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

3737

Multi-level thresholding◼ A point (x,y) belongs-

◼ to an object class if T1 < f(x,y) T2

◼ to another object class if f(x,y) > T2

◼ to background if f(x,y) T1

◼ T depends on ◼ only f(x,y) : only on gray-level values Global

threshold

◼ both f(x,y) and p(x,y) : on gray-level values and its neighbors Local threshold

◼ f(x,y), p(x,y) and (x,y) : on gray-level values, its neighbors and pixel location Adaptive threshold

Page 38: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

38

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

Page 39: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

3939

Basic Global Thresholding: Example

generate binary image

use T midway between the max and min gray levels-

Page 40: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

4040

Basic Global Thresholding Algorithm

◼ Based on visual inspection of histogram1. Select an initial estimate for T.2. Segment the image using T. This will produce two

groups of pixels: G1 consisting of all pixels with gray level values > T and G2 consisting of pixels with gray level values T

3. Compute the average gray level values 1 and 2 for the pixels in regions G1 and G2

4. Compute a new threshold value5. T = 0.5 (1 + 2)6. Repeat steps 2 through 4 until the difference in T in

successive iterations is smaller than a predefined parameter To.

Page 41: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

4141

Basic Adaptive Thresholding

◼ Subdivide original image into small areas.

◼ Utilize a different threshold to segmenteach subimages.

◼ Since the threshold used for each pixeldepends on the location of the pixel interms of the subimages, this type ofthresholding is adaptive.

Page 42: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

4242

The Role of Illumination

f(x,y) = i(x,y) r(x,y)

a) computer generated reflectance functionb) histogram of reflectance functionc) computer generated illumination function (poor)d) product of a) and c)e) histogram of product image

Page 43: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

4343

Example : Adaptive Thresholding

Page 44: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

4444

Further subdivisiona). Properly and improperly segmented subimages from previous example b)-c). corresponding histogramsd). further subdivision of the improperly segmented subimage.e). histogram of small subimage at topf). result of adaptively segmenting d).

Page 45: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

45

Automatic thresholding method

◼ Otsu’s method

Page 46: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

46

Optimal global 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 47: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

47

Otsu’s Thresholding Method

◼ Based on a very simple idea: Find the threshold thatminimizes the weighted within-class variance.

◼ This turns out to be the same as maximizing thebetween-class variance.

◼ Operates directly on the gray level histogram [e.g.256 numbers, P(i)], so it’s fast (once the histogram iscomputed).

◼ Basic idea is that well-thresholded classes should bedistinct w.r.t. intensity values and conversely athreshold giving the best separation between classeswould be the best (optimum) threshold.

(1979)

Page 48: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

48

Matlab function for Otsu’s method

◼ function level = graythresh(I)◼ GRAYTHRESH Compute global thresholdusing Otsu's method. Level is a normalized intensity value that lies in the range [0, 1].

Page 49: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

49

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

Region based segmentation

Page 50: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

Region Growing

◼ Region-growing approaches exploit the fact that pixels which are close together have similar gray values.

◼ Algorithm-

Page 51: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

51

◼ Let R represent the entire image region.

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

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) =

Region Growing- Properties

• Drawbacks: large execution time, selection of homogeneity property, selection of seed.

Page 52: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

5252

Region Growing

criteria:1. The absolute gray-

level difference between any pixel and the seed has to be less than 65

2. The pixel has to be 8-connected to at least one pixel in that region (if more, the regions are merged)

Page 53: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

53

Region Splitting◼ The opposite approach to region growing is

region splitting.◼ It is a top-down approach and it starts with

the assumption that the entire image ishomogeneous

◼ If not, then the method requires that theregion be split into two regions.

◼ If this is not true, the image is split into foursub images

◼ This splitting procedure is repeatedrecursively until we split the image intohomogeneous (uniform) regions

Page 54: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

54

Region Splitting◼ One method to divide a region is to use a quadtree

structure.

◼ Quadtree: a tree in which nodes have exactly fourdescendants.

Page 55: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

55

Split

◼ Splitting techniques disadvantage- they create regions that may be adjacent and homogeneous, but not merged.

Page 56: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

56

◼ Opposite to region split-bottom-up method

- Remove child nodes if parent node satisfy the desired property.

- Image size must be in integer powers of 2.

- If most of the homogeneous regions are small, then split technique is inferior to merge technique in terms of time requirement and vice versa.

- Split and Merge: If no priori knowledge is available start somewhere at the middle level.

Region Merging

Page 57: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

Region Merging

Page 58: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

Region Splitting and Merging

Page 59: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

59

Applications

◼ 3D – Imaging

◼ Several applications in the field of MRI

Page 60: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

60

Edge linking and Boundary detection

◼ Local processing

◼ Global processing

Page 61: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

61

◼ Two properties of edge points are useful for edgelinking:◼ the strength (or magnitude) of the detected edge points

◼ their directions (determined from gradient directions)

◼ Adjacent edge points with similar magnitude anddirection are linked.

◼ For example, an edge pixel with coordinates (x0,y0) in apredefined neighborhood of (x,y) is similar to the pixelat (x,y) if,

Local processing

Page 62: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

62

Local processing example

Page 63: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

63

Global Processing

◼ Hough Transform can be used todetermine whether points lie on a curveof a specified shape

Page 64: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

64

Hough Transform – Line Detection

◼ Consider the slope-intercept equationof line:

◼ Rewrite the equation as follows:

(a, b are constants, x is a variable, y is a function of x)

(now, x, y are constants, a is a variable, b is a function of a)

P.V.C. Hough, Machine Analysis of Bubble Chamber Pictures, Proc. Int. Conf. High Energy Accelerators and Instrumentation, 1959

Page 65: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

65

◼ 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 +=

Hough transform

Page 66: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

66

Properties in slope-intercept space

◼ Each point (xi , yi) defines a line in thea − b space (parameter space).

◼ Points lying on the same line in the x − yspace, define lines in the parameterspace which all intersect at the samepoint.

◼ The coordinates of the point ofintersection define the parameters ofthe line in the x − y space.

Page 67: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

67

HT Algorithm

1. Quantize parameter space (a,b):

P[amin, . . . , amax][bmin, . . . , bmax] (accumulator array)

amax

Page 68: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

68

Algorithm (cont’d)

2. For each edge point (x, y)

For(a = amin; a ≤ amax; a++) {b = − xa + y; /* round off if needed *

(P[a][b])++; /* voting */}

3. Find local maxima in P[a][b]

if P[a j][bk]=M, then M points lie on the liney = a j x + bk

Page 69: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

69

Polar Representation of Lines

(no problem with vertical lines, i.e., θ =90)

ρ−θ space

Page 70: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

70

Example

long

vertical

lines

Page 71: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

71

Using the Hough transform for edge linking

Page 72: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

7272

Morphology

◼ Morphological image processing is used toextract image components for representationand description of region shape, such asboundaries, skeletons, convex hull etc.

Page 73: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

7373

Z2 and Z3

◼ Set in mathematical morphologyrepresent objects in an image◼ binary image (0 = white, 1 = black) : the

element of the set is the coordinates (x,y)of pixel belong to the object Z2

◼ gray-scaled image : the element of the set is thecoordinates (x,y) of pixel belong to the object andthe gray levels Z3

Page 74: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

7474

Basic Set Theory

Page 75: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

7575

Reflection and Translation

} ,|{ˆ Bfor bbwwB −=

} ,|{)( Afor azaccA z +=

Page 76: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

7676

Example

Page 77: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

77

Structuring element (SE)

77

▪ small set to probe the image under study▪ for each SE, define origin▪ shape and size must be adapted to geometricproperties for the objects

Page 78: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

78

How to describe SE

◼ many different ways!

◼ information needed:◼ position of origin for SE

◼ positions of elements belonging to SE

78

Page 79: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

79

Examples of Structuring element (SE)

Page 80: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

80

Basic morphological operations

◼ Erosion

◼ Dilation

◼ combine to◼ Opening object

◼ Closing background

80

keep general shape but smooth with respect to

Page 81: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

81

Erosion

◼ Erosion of a set A by structuring element B: all z in A such that B is in A when origin of B=z

shrink the object

81

}{ Az|(B)BA z =−The set of all points such that , translated by , is contained by .z B z A

| ( ) c

ZA B z B A= =

Page 82: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

8282

}{ Az|(B)BA z =−

Page 83: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

83

Page 84: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

84

Dilation

◼ Dilation of a set A by structuring element B: all z in A such that B hits A when origin of B=z

◼ grow the object

84

}ˆ{ ΦA)Bz|(BA z =

Page 85: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

8585

Dilation

}ˆ{ ΦA)Bz|(BA z =

B = structuring element

Page 86: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

8686

Dilation : Bridging gaps

Page 87: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

87

Opening and Closing

◼ Opening generally smoothes the contourof an object and eliminates thinprotrusions

◼ Closing tends to smooth sections ofcontours but it generates fuses narrowbreaks and long thin gulfs, eliminatessmall holes, and fills gaps in the contour

Page 88: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

88

Opening

Erosion followed by dilation, denoted ∘

◼ eliminates protrusions

◼ breaks necks

◼ smooths contour

88

BBABA −= )(

Page 89: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

8989

Opening

BBABA −= )(})(|){( ABBBA zz =

Page 90: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

90

Closing

Dilation followed by erosion, denoted •

◼ smooth contour

◼ fuse narrow breaks and long thin gulfs

◼ eliminate small holes

◼ fill gaps in the contour

90

BBABA −=• )(

Page 91: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

9191

Closing

BBABA −=• )(

Page 92: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

9292

Properties

Opening(i) AB is a subset (subimage) of A(ii) If C is a subset of D, then C B is a subset of D B(iii) (A B) B = A B

Closing(i) A is a subset (subimage) of A•B(ii) If C is a subset of D, then C •B is a subset of D •B(iii) (A •B) •B = A •B

Note: repeated openings/closings has no effect!

Page 93: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

9393

Page 94: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

9494

Page 95: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

95

Hit-or-Miss Transformation ⊛ (HMT)

◼ find location of one shape among a set of shapes template matching

◼ composite SE: object part (B1) and background part (B2)

◼ does B1 fits the object while, simultaneously, B2 misses the object, i.e., fits the background?

95

Page 96: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

9696

Hit-or-Miss Transformation

)]([)( XWAXABA c −−−=

Page 97: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

9797

Boundary Extraction

)()( BAAA −−=

Page 98: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

9898

Example

Page 99: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

9999

Thinning

cBAA

BAABA

)(

)(

=

−=

Page 100: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

100100

Thickening

)( BAABA =•

Page 101: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

101101

SkeletonsK

kk ASAS

0

)()(=

=

BkBAkBAASk )()()( −−−=

})(|max{ −= kBAkK

))((0

kBASA k

K

k=

=

Page 102: Chapter 4: Image Segmentation · 7 Point Detection Point (isolated) detection can be achieved simply using the mask above A point can be detected at the location on which the mask

102

Thank you !