morphological operatorsmtoledo/6088/2011/6_morphologicalops.pdf · morphological operators the...

20
Morphological Operators INEL 6088 - Fall 2011 - M. Toledo Tuesday, September 13, 11

Upload: others

Post on 01-Nov-2020

12 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Morphological Operatorsmtoledo/6088/2011/6_MorphologicalOps.pdf · Morphological Operators The vector sum of pixels p and q with indeces (i,j) and (k,l) is the pixel p+q with indices

Morphological Operators

INEL 6088 - Fall 2011 - M. Toledo

Tuesday, September 13, 11

Page 2: Morphological Operatorsmtoledo/6088/2011/6_MorphologicalOps.pdf · Morphological Operators The vector sum of pixels p and q with indeces (i,j) and (k,l) is the pixel p+q with indices

Morphological Operators

The vector sum of pixels p and q with indeces (i,j) and (k,l) is the pixel p+q with indices (i+k,j+l). The vector difference p-q is the pixel with indices (i-k,j-l).

The translation of a binary image A by pixel p is an image given by:

Intersection of A and B: binary image which is 1 at all pixels p which are 1 in both A and B

Union of A and B: binary image which is 1 at all pixels which are 1 in A or in B, or in both.

Complement of A: Ω is a universal binary image (all 1’s)

Tuesday, September 13, 11

Page 3: Morphological Operatorsmtoledo/6088/2011/6_MorphologicalOps.pdf · Morphological Operators The vector sum of pixels p and q with indeces (i,j) and (k,l) is the pixel p+q with indices

Binary Image Morphological Operations

Morphology refers to form or shape.

Morphological operations use a binary image and a structuring element, which is another, much smaller, binary image.

origin

Original image A (left) and structuring element S (right). The origin of the

structuring element is darker than other pixels in B

Tuesday, September 13, 11

Page 4: Morphological Operatorsmtoledo/6088/2011/6_MorphologicalOps.pdf · Morphological Operators The vector sum of pixels p and q with indeces (i,j) and (k,l) is the pixel p+q with indices

Dilation: A⊕S=∪b∈S Ab

Alternative description: the structuring element S is swept over the image; each t ime the or ig in of the structuring element is over a 1-pixel on the image, the entire structuring element is “Boolean OR-ed” to produce the output image.

During a dilation operation, every pixel in the structuring element will be present in the final image if the structuring element origin is over a 1-pixel of the original image.

Each 1 in S describes a shift of the image in the direction of the vector from the origin to the location. When several shifts are prescribed by the mask S, the resulting shifted images are combined by a set of union operations.

translation of A by b

Tuesday, September 13, 11

Page 5: Morphological Operatorsmtoledo/6088/2011/6_MorphologicalOps.pdf · Morphological Operators The vector sum of pixels p and q with indeces (i,j) and (k,l) is the pixel p+q with indices

Dilation of A by B. Original figure A shown as a bold line.

Tuesday, September 13, 11

Page 6: Morphological Operatorsmtoledo/6088/2011/6_MorphologicalOps.pdf · Morphological Operators The vector sum of pixels p and q with indeces (i,j) and (k,l) is the pixel p+q with indices

1

1 1

1 1 1

1 1 1

1 1 1

1 1 1

1 1

Identity operation

Left shift

Horizontal thickening

Isotropic thickening

Symmetrical Horizontal thickening

Examples of dilation masks and their effect

Tuesday, September 13, 11

Page 7: Morphological Operatorsmtoledo/6088/2011/6_MorphologicalOps.pdf · Morphological Operators The vector sum of pixels p and q with indeces (i,j) and (k,l) is the pixel p+q with indices

Al te rna t i ve desc r ip t i on : The structuring element S is swept over the image. Each time the origin of S is over a 1-pixel on the image, the corresponding pixel in the resulting image is 1 only if all pixels in S are over 1-pixels in the original image.

Erosion: A⊖S = ∩b∈S A-b

Original image’s boundary

Each 1 in S describes a shift of the image in the direction of the vector from the location to the origin. When several shifts are prescribed by the mask S, the resulting shifted images are combined by a set of intersection operations.

Tuesday, September 13, 11

Page 8: Morphological Operatorsmtoledo/6088/2011/6_MorphologicalOps.pdf · Morphological Operators The vector sum of pixels p and q with indeces (i,j) and (k,l) is the pixel p+q with indices

Other Structuring Elements

(taken from “Computer Vision” by Shapiro and Stockman)

Tuesday, September 13, 11

Page 9: Morphological Operatorsmtoledo/6088/2011/6_MorphologicalOps.pdf · Morphological Operators The vector sum of pixels p and q with indeces (i,j) and (k,l) is the pixel p+q with indices

Geometric complement: reflection = binary image Br which is symmetric with B about the origin;

Geometric duality of dilation and erosion:

Logical duality (de Morgan)

(A ⊕ B)C = AC⊖Br

(A ⊖ B)C = AC ⊕ Br

Br = {-p | p ∈ B}

(A ∪ B)C = AC ∩ BC

(A ∩ B)C = AC ∪ BC

Tuesday, September 13, 11

Page 10: Morphological Operatorsmtoledo/6088/2011/6_MorphologicalOps.pdf · Morphological Operators The vector sum of pixels p and q with indeces (i,j) and (k,l) is the pixel p+q with indices

Previous result

Complement of A and the reflection of B. The structuring element’s origin is still the darker pixel.

Dual of dilation: eroding A’s background with the B’s reflection.

Tuesday, September 13, 11

Page 11: Morphological Operatorsmtoledo/6088/2011/6_MorphologicalOps.pdf · Morphological Operators The vector sum of pixels p and q with indeces (i,j) and (k,l) is the pixel p+q with indices

Dual of erosion: dilation of A’s background with B’s reflection

Tuesday, September 13, 11

Page 12: Morphological Operatorsmtoledo/6088/2011/6_MorphologicalOps.pdf · Morphological Operators The vector sum of pixels p and q with indeces (i,j) and (k,l) is the pixel p+q with indices

(A ⊕ B) ⊕ C = A ⊕ (B ⊕ C) dilations are associatives

(A ⊖ B) ⊖ C = A ⊖ (B ⊕ C) erosions are not assoc.

X ⊕ Y = Y ⊕ X X ⊖ Y = Y ⊖ X

boundary = A - (A ⊖ B)

Tuesday, September 13, 11

Page 13: Morphological Operatorsmtoledo/6088/2011/6_MorphologicalOps.pdf · Morphological Operators The vector sum of pixels p and q with indeces (i,j) and (k,l) is the pixel p+q with indices

O p e n i n g : e r o s i o n followed by dilation with the same structuring element. Will remove all pixels in regions that are too small to contain S.

A○B=(A⊖B)⊕B

Closing : a d i lat ion followed by erosion. C a n b e u s e d t o s u p p r e s s s p a t i a l features or discriminate against objects based upon their size.

A⦁B=(A⊕B)⊖B

Opening: erosion, shown on left, is followed by dilation. Final result shown at right.

Closing: dilation, shown on left, is followed by erosion. Final result shown at right.

Tuesday, September 13, 11

Page 14: Morphological Operatorsmtoledo/6088/2011/6_MorphologicalOps.pdf · Morphological Operators The vector sum of pixels p and q with indeces (i,j) and (k,l) is the pixel p+q with indices

8.3 Mathematical Morphology 2 4 3

(a)

1

1 1 . • 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 • 1 1 1 1 1 . . . . . . . . 1 1

1 1

(b) (c)

' 1111 • 1111 • -1111 • 1 1 1 1 1 1 1 1 1 1

•11111 • 1111 • 1111 . 1111 . . 1 1 1 •

1 1 1 • 1 1 1 -1 1 1 -1111 1111 1111 1111 1 1 1 1 1 • 1 1 1 1 1 • 1 1 1 1 1 . 1 1 1 1 1 .

1 1 1 1 1 1 1 1 1 • 1 1

(d) (e)

• - 1 1 1 1 1 1 1

• • 1 •• . 1 1 1 I l l

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

1 1 1 1

Mgure 8.1 Results of morphological operations, (a) shows the original image, (b) the dilated image, (c) :he eroded image, (d) the closed image, and (e) the opened image.

applications. Furthermore, by subtracting the derived image from the original mage, it is possible to locate many sorts of defects, including those cited above as

being eliminated by opening and closing: this possibiUty makes the two operations 3ven more important. For example, we might use the following operation to locate

Tuesday, September 13, 11

Page 15: Morphological Operatorsmtoledo/6088/2011/6_MorphologicalOps.pdf · Morphological Operators The vector sum of pixels p and q with indeces (i,j) and (k,l) is the pixel p+q with indices

8.3 Mathematical Morphology 2 4 7

id) (e) Figure 8.3 Use of the opening operation, (a) shows a thresholded peppercorn image, (b) shows the result of applying a.1 xl erosion operation to the object shapes, and (c) shows the effect of subsequently applying a 7 x 7 dilation operation. The overall effect of the two operations is an "opening" operation. In this case, opening is useful for eliminating the twiglet. (d) and (e) show the same respective operations when appUed within an 11 x 11 window. Here some size filtering of the peppercorns has been achieved, and all the peppercorns have been separated—thereby helping with subsequent counting and labeling operations.

246 CHAPTER 8 Mathematical Morphology

and mask sizes is of vital importance in the design of complete algorithms for all these tasks. Figures 8.2 and 8.3 illustrate some of these possibilities in the case of a peppercorn image: some of the interest in this image relates to the presence of a twiglet and how it is eliminated from consideration and/or identified.

JBjBl

" • * 1 • • , •

• • • •

# * • ^

• J ^ (a) ib)

(c) id) Figure 8.2 Use of the closing operation, {a) shows a peppercorn image, and {b) shows the result of thresholding, (c) shows the result of applying a 3 x 3 dilation operation to the object shapes, and {d) shows the effect of subsequently applying a 3 x 3 erosion operation. The overall effect of the two operations is a "closing" operation. In this case, closing is useful for eliminating the small holes in the objects. This would, for example, be useful for helping to prevent misleading loops from appearing in skeletons. For this picture, extremely large window operations would be required to group peppercorns into regions.

Tuesday, September 13, 11

Page 16: Morphological Operatorsmtoledo/6088/2011/6_MorphologicalOps.pdf · Morphological Operators The vector sum of pixels p and q with indeces (i,j) and (k,l) is the pixel p+q with indices

Tuesday, September 13, 11

Page 17: Morphological Operatorsmtoledo/6088/2011/6_MorphologicalOps.pdf · Morphological Operators The vector sum of pixels p and q with indeces (i,j) and (k,l) is the pixel p+q with indices

From Sternberg, S.R. 1985“An Overview of Image Algebra using Mathematical Morphology”Integrated Technology for Parallel Image ProcessingAcademic Press, London, 79-100

Tuesday, September 13, 11

Page 18: Morphological Operatorsmtoledo/6088/2011/6_MorphologicalOps.pdf · Morphological Operators The vector sum of pixels p and q with indeces (i,j) and (k,l) is the pixel p+q with indices

Structuring elements used by Sternberg:• hole_ring: a ring of pixels whose diameter is slightly larger than the diameters of the 4 holes in the watch gears. It fits just around these holes and can be used to mark their centers.• hole_mask: an octagon slightly larger than the holes• gear_body: a disk structuring element that is as big as the gear minus its teeth• sampling_ring_spacer: a disk s.e. that is used to move slightly outward from the gear body.• sampling_ring_width: disk s.e. used to dilate outward to the tips of the teeth• tip_spacing: a disk s.e. whose diameter spans the tip-to-tip space between teeth.

Steps to produce figure 3.15(e):• open B3 with gear_body to get rid of the teeth• dilate with sampling_ring_spacer to bring it out of the base of the teeth• dilate that with sampling_ring_width to bring the image out to the tip of the tip• subtract the second from the last result to get a ring that just fit over the tip

Tuesday, September 13, 11

Page 19: Morphological Operatorsmtoledo/6088/2011/6_MorphologicalOps.pdf · Morphological Operators The vector sum of pixels p and q with indeces (i,j) and (k,l) is the pixel p+q with indices

A⌦ (B,C) = (A B) \ (AC C)

Hit and Miss Transform

Can be used to search an image for instances of a shape (pattern matching)

erosion

se 1

se 2

A’s background

Tuesday, September 13, 11

Page 20: Morphological Operatorsmtoledo/6088/2011/6_MorphologicalOps.pdf · Morphological Operators The vector sum of pixels p and q with indeces (i,j) and (k,l) is the pixel p+q with indices

A�B = max

b2BAb

A B = min

b2BA�b

G = (A�B)� (A B)

Gray-scale dilation/erosion

Dilation: select the largest grayscale value for all pixels under the mask B

Erosion: select the smallest grayscale value for all pixel under mask B

G = morphological gradient. The operation enhances the image edges.

Tuesday, September 13, 11