Lecture Two for teens. Introduction to Morphological Operators.

133
Lecture Two Lecture Two for teens for teens

Transcript of Lecture Two for teens. Introduction to Morphological Operators.

Page 1: Lecture Two for teens. Introduction to Morphological Operators.

Lecture Two for Lecture Two for teensteens

Page 2: Lecture Two for teens. Introduction to Morphological Operators.

Introduction to Introduction to Morphological Morphological

OperatorsOperators

Page 3: Lecture Two for teens. Introduction to Morphological Operators.

About this lecture

• In this lecture we introduce INFORMALLY the most important operations based on morphology, just to give you the intuitive feeling.

• In next lectures we will introduce more formalism and more examples.

Page 4: Lecture Two for teens. Introduction to Morphological Operators.

Binary Morphological Processing

• Non-linear image processing technique– Order of sequence of operations is important

• Linear: (3+2)*3 = (5)*3=153*3+2*3=9+6=15

• Non-linear: (3+2)2 + (5)2 =25 [sum, then square] (3)2 + (2)2 =9+4=13 [square, then sum]

• Based on geometric structure• Used for edge detection, noise removal and feature

extraction Used to ‘understand’ the shape/form of a binary image

Page 5: Lecture Two for teens. Introduction to Morphological Operators.

Introduction

• Structuring Element• Erosion• Dilation• Opening• Closing• Hit-and-miss• Thinning• Thickening

Page 6: Lecture Two for teens. Introduction to Morphological Operators.

1D 1D Morphological Morphological

OperationsOperations

Page 7: Lecture Two for teens. Introduction to Morphological Operators.

Example for 1D ErosionExample for 1D Erosion

1 0 0 0 1 1 1 0 1 1Input image

Structuring Element

0Output Image

111

Page 8: Lecture Two for teens. Introduction to Morphological Operators.

Example for Erosion

1 0 0 0 1 1 1 0 1 1Input image

Structuring Element

0 0Output Image

111

Page 9: Lecture Two for teens. Introduction to Morphological Operators.

Example for Erosion

1 0 0 0 1 1 1 0 1 1Input image

Structuring Element

0 0 0Output Image

111

Page 10: Lecture Two for teens. Introduction to Morphological Operators.

Example for Erosion

1 0 0 0 1 1 1 0 1 1Input image

Structuring Element

0 0 0 0Output Image

111

Page 11: Lecture Two for teens. Introduction to Morphological Operators.

Example for Erosion

1 0 0 0 1 1 1 0 1 1Input image

Structuring Element

0 0 0 0 1Output Image

111

Structured element is completely included in set of ones

Page 12: Lecture Two for teens. Introduction to Morphological Operators.

Example for Erosion

1 0 0 0 1 1 1 0 1 1Input image

Structuring Element

0 0 0 0 1 0Output Image

111

Page 13: Lecture Two for teens. Introduction to Morphological Operators.

Example for Erosion

1 0 0 0 1 1 1 0 1 1Input image

Structuring Element

0 0 0 0 1 0 0Output Image

111

Page 14: Lecture Two for teens. Introduction to Morphological Operators.

Example for Erosion

1 0 0 0 1 1 1 0 1 1Input image

Structuring Element

0 0 0 0 1 0 0 0Output Image

111

Page 15: Lecture Two for teens. Introduction to Morphological Operators.

Example for 1D DilationExample for 1D Dilation

1 0 0 0 1 1 1 0 1 1Input image

Structuring Element

1Output Image

111

Structuring element overlaps with input image

Page 16: Lecture Two for teens. Introduction to Morphological Operators.

Example for Dilation

1 0 0 0 1 1 1 0 1 1Input image

Structuring Element

1 0Output Image

111

Page 17: Lecture Two for teens. Introduction to Morphological Operators.

Example for Dilation

1 0 0 0 1 1 1 0 1 1Input image

Structuring Element

1 0 1Output Image

111

Page 18: Lecture Two for teens. Introduction to Morphological Operators.

Example for Dilation

1 0 0 0 1 1 1 0 1 1Input image

Structuring Element

1 0 1 1Output Image

111

Page 19: Lecture Two for teens. Introduction to Morphological Operators.

Example for Dilation

1 0 0 0 1 1 1 0 1 1Input image

Structuring Element

1 0 1 1 1Output Image

111

Page 20: Lecture Two for teens. Introduction to Morphological Operators.

Example for Dilation

1 0 0 0 1 1 1 0 1 1Input image

Structuring Element

1 0 1 1 1 1Output Image

111

Page 21: Lecture Two for teens. Introduction to Morphological Operators.

Example for Dilation

1 0 0 0 1 1 1 0 1 1Input image

Structuring Element

1 0 1 1 1 1 1Output Image

111

Page 22: Lecture Two for teens. Introduction to Morphological Operators.

Example for Dilation

1 0 0 0 1 1 1 0 1 1Input image

Structuring Element

1 0 1 1 1 1 1 1Output Image

111

Page 23: Lecture Two for teens. Introduction to Morphological Operators.

2D 2D Morphological Morphological

OperationsOperations

Page 24: Lecture Two for teens. Introduction to Morphological Operators.

Image – Set of Pixels• Basic idea is to treat an object within an image

as a set of pixels set of pixels (or coordinates of pixels)

• In binary images, pixels that are ‘off’, set to 0, are background and appear black.

• Foreground pixels (objects) are 1 and appear white

Page 25: Lecture Two for teens. Introduction to Morphological Operators.

NeighborhoodNeighborhood• Set of pixels defined by their location

relation to the pixel of interest– Defined by structuring element– Specified by connectivity

• Connectivity- – ‘4-connected’ – ‘8-connected’

Page 26: Lecture Two for teens. Introduction to Morphological Operators.

Labeling Connected Components

• Label objects in an image

• 4-Neighbors

• 8-Neighbors

p p

Page 27: Lecture Two for teens. Introduction to Morphological Operators.

4 and 8 Connect

Input Image 8 – Connect 4 - Connect

Page 28: Lecture Two for teens. Introduction to Morphological Operators.

Morphological Image ProcessingMorphological Image ProcessingMorphological Image ProcessingMorphological Image Processing

From: Digital Image Processing, Gonzalez,Woods And EddinsBasic operations on

shapes

Page 29: Lecture Two for teens. Introduction to Morphological Operators.

Morphological Image Morphological Image ProcessingProcessing

Morphological Image Morphological Image ProcessingProcessing

From: Digital Image Processing, Gonzalez,Woods And Eddins

Page 30: Lecture Two for teens. Introduction to Morphological Operators.

Operations on binary Operations on binary images in MATLABimages in MATLAB

Operations on binary Operations on binary images in MATLABimages in MATLAB

From: Digital Image Processing, Gonzalez,Woods And Eddins

Page 31: Lecture Two for teens. Introduction to Morphological Operators.

Translation of Object A by vector b

• Define Translation ob object A by vector b:At = { t I2 : t = a+b, a A }

Where I2 is the two dimensional image space that contains the image

• Definition of DILATION is the UNION of all the translations:

A B = { t I2 : t = a+b, a A } for all b’s in B

Page 32: Lecture Two for teens. Introduction to Morphological Operators.

Structuring Element (Kernel)• Structuring Elements can have varying sizes• Usually, element values are 0,1 and none(!)• Structural Elements have an origin• For thinning, other values are possible• Empty spots in the Structuring Elements are don’t

care’s!

Apr 20, 2023 32

Box

Disc

Examples of stucturing elements

Page 33: Lecture Two for teens. Introduction to Morphological Operators.

Reflection of the structuring Reflection of the structuring elementelement

Reflection of the structuring Reflection of the structuring elementelement

From: Digital Image Processing, Gonzalez,Woods And Eddins

Page 34: Lecture Two for teens. Introduction to Morphological Operators.

Idea of DILATION versus Idea of DILATION versus TRANSLATIONTRANSLATION

Object B is one point located at (a,0) A1: Object A is translated by object B

Since dilation is the union of all the translations, A B = At where the set union is for all the b’s in B, the dilation of rectangle A in the positive x direction by a results in rectangle A1 (same size as A, just translated to the right)

A1A

Page 35: Lecture Two for teens. Introduction to Morphological Operators.

DILATION – B has 2 Elements

Object B is 2 points, (a,0), (-a,0) There are two translations of A as result of two elements in B

Dilation is defined as the UNION of the objectsA1 and A2.

NOT THE INTERSECTION

A2 A1(part of A1 is under A2)

A

-a a -a a

Page 36: Lecture Two for teens. Introduction to Morphological Operators.

2D 2D DILATIONDILATION

Page 37: Lecture Two for teens. Introduction to Morphological Operators.

DILATION Rounded corners

Round Structuring Element (SE) can be interpretedas rolling the SE around the contour of the object.New object has rounded corners and is larger in every direction by½ width of the SE

Page 38: Lecture Two for teens. Introduction to Morphological Operators.

DILATIONRounded corners

Square Structuring Element (SE) can be interpretedas moving the SE around the contour of the object.New object has square corners and is larger in every direction by½ width of the SE

Page 39: Lecture Two for teens. Introduction to Morphological Operators.

DILATION

• The shape of B determines the final shape of the dilated object.

• B acts as a geometric filter that changes the geometric structure of A

Page 40: Lecture Two for teens. Introduction to Morphological Operators.

2D 2D EROSIONEROSION

Page 41: Lecture Two for teens. Introduction to Morphological Operators.

Another important operator

• Introduction to Morphological Operators

– Used generally on binary images, e.g., background subtraction results!

– Used on gray value images, if viewed as a stack to binary images.

• Good for, e.g.,– Noise removal in background

– Removal of holes in foreground / background

• Check: www.cee.hw.ac.uk/hipr

Page 42: Lecture Two for teens. Introduction to Morphological Operators.

A first Example: Erosion

• Erosion is an important morphological operation

• Applied Structuring Element:

Page 43: Lecture Two for teens. Introduction to Morphological Operators.

Dilation versus ErosionDilation versus Erosion

• Basic operations

• Are dual to each other:– ErosionErosion shrinks foreground, enlarges

Background

– Dilation enlarges foreground, shrinks background

Page 44: Lecture Two for teens. Introduction to Morphological Operators.

Erosion

• Erosion is the set of all points in the image, where the structuring element “fits into”.

• Consider each foreground pixel in the input image– If the structuring element fits in, write a “1” at the

origin of the structuring element!

• Simple application of pattern matching• Input:

– Binary Image (Gray value)– Structuring Element, containing only 1s!

Page 45: Lecture Two for teens. Introduction to Morphological Operators.

Another example of erosion

• White = 0, black = 1, dual property, image as a result of erosion gets darker

Page 46: Lecture Two for teens. Introduction to Morphological Operators.

Introduction to Introduction to Erosion on Erosion on Gray Value ImagesGray Value Images

• View gray value images as a stack of binary images!stack of binary images!

Intensity is lower so the image is darker

Page 47: Lecture Two for teens. Introduction to Morphological Operators.

Erosion on Gray Value Images

• Images get darker!

Page 48: Lecture Two for teens. Introduction to Morphological Operators.

Example: Counting CoinsExample: Counting Coins

• Counting coins is difficult because they touch each other!

• Solution: Binarization and Erosion separates them!

Page 49: Lecture Two for teens. Introduction to Morphological Operators.

DILATION DILATION more detailsmore details

Page 50: Lecture Two for teens. Introduction to Morphological Operators.

Example: Dilation• Dilation is an important morphological

operation

• Applied Structuring Element:

Page 51: Lecture Two for teens. Introduction to Morphological Operators.

Dilation

• Dilation is the set of all points in the image, where the structuring element “touches” the foreground.

• Consider each pixel in the input image– If the structuring element touches the foreground

image, write a “1” at the origin of the structuring element!

• Input:– Binary Image

– Structuring Element, containing only 1s!!

Page 52: Lecture Two for teens. Introduction to Morphological Operators.

Another Dilation Example

• Image get lighter, more uniform intensity

Page 53: Lecture Two for teens. Introduction to Morphological Operators.

Dilation on Gray Value ImagesDilation on Gray Value Images

• View gray value images as a stack of binary images!

Page 54: Lecture Two for teens. Introduction to Morphological Operators.

Dilation on Gray Value Images

• More uniform intensity

Page 55: Lecture Two for teens. Introduction to Morphological Operators.

Edge DetectionEdge Detection• Edge Detection

1. Dilate input image

2. Subtract input image from dilated image

3. Edges remain!

Page 56: Lecture Two for teens. Introduction to Morphological Operators.

From: Digital Image Processing, Gonzalez,Woods And Eddins

Illustration of dilationIllustration of dilation

Page 57: Lecture Two for teens. Introduction to Morphological Operators.

>> I = zeros([13 19]);>> I(6,6:8)=1;>> I2 = imdilate(I,se);

0.5 1 1.5 2 2.5 3 3.5

0.5

1

1.5

2

2.5

3

3.5

2 4 6 8 10 12 14 16 18

2

4

6

8

10

12

2 4 6 8 10 12 14 16 18

2

4

6

8

10

12

Example of Dilation in MatlabExample of Dilation in Matlab

Page 58: Lecture Two for teens. Introduction to Morphological Operators.

Imdilate Imdilate function in MATLABfunction in MATLABIM2 = IMDILATE(IM,NHOOD) dilates the image IM, where NHOOD is a matrix of 0s and 1s that specifies the structuring element neighborhood. This is equivalent to the syntax IIMDILATE(IM, STREL(NHOOD)). IMDILATE determines the center element of the neighborhood by FLOOR((SIZE(NHOOD) + 1)/2).

>> se = imrotate(eye(3),90)se =

0 0 1 0 1 0 1 0 0

>> ctr=floor(size(se)+1)/2ctr = 2 2

Page 59: Lecture Two for teens. Introduction to Morphological Operators.

MATLAB Dilation ExampleMATLAB Dilation Example

>> I = zeros([13 19]);>> I(6, 6:12)=1;>> SE = imrotate(eye(5),90);>> I2=imdilate(I,SE);>> figure, imagesc(I)>> figure, imagesc(SE)>> figure, imagesc(I2)

Page 60: Lecture Two for teens. Introduction to Morphological Operators.

SE

DILATED IMAGEINPUT IMAGE

Page 61: Lecture Two for teens. Introduction to Morphological Operators.

>> I(6:9,6:13)=1;>> figure, imagesc(I)>> I2=imdilate(I,SE);>> figure, imagesc(I2)

I I2

SE

Page 62: Lecture Two for teens. Introduction to Morphological Operators.

SE =

1 1 1 1 1 1 1 1 1

I I2

Page 63: Lecture Two for teens. Introduction to Morphological Operators.

Dilation and Dilation and ErosionErosion

Page 64: Lecture Two for teens. Introduction to Morphological Operators.

Dilation and Erosion

• DILATION: Adds pixels to the boundary of an object

• EROSIN: Removes pixels from the boundary of an object

• Number of pixels added or removed depends on size and shape of structuring element

Page 65: Lecture Two for teens. Introduction to Morphological Operators.

From: Digital Image Processing, Gonzalez,Woods And Eddins

Illustration of ErosionIllustration of Erosion

Page 66: Lecture Two for teens. Introduction to Morphological Operators.

MATLAB Erosion ExampleMATLAB Erosion Example

I3=imerode(I2,SE);

2 pixelwide

SE = 3x3

Page 67: Lecture Two for teens. Introduction to Morphological Operators.

Illustration of erosionIllustration of erosionIllustration of erosionIllustration of erosion

From: Digital Image Processing, Gonzalez,Woods And Eddins

Page 68: Lecture Two for teens. Introduction to Morphological Operators.

Combinations

• In most morphological applications dilation and erosion are used in combination

• May use same or different structuring elements

Page 69: Lecture Two for teens. Introduction to Morphological Operators.

Opening & ClosingOpening & Closing• Important operations

• Derived from the fundamental operations – Dilatation– Erosion

• Usually applied to binary images, but gray value images are also possible

• Opening and closing are dual operations

Page 70: Lecture Two for teens. Introduction to Morphological Operators.

OPENINGOPENING

Page 71: Lecture Two for teens. Introduction to Morphological Operators.

Opening

• Similar to Erosion– Spot and noise removal– Less destructive

• Erosion next dilation• the same structuring element for both operations.• Input:

– Binary Image– Structuring Element, containing only 1s!

Page 72: Lecture Two for teens. Introduction to Morphological Operators.

Opening

• Take the structuring element (SE) and slide it around inside each foreground region. – All pixels which can be covered by the SE with the SE

being entirely within the foreground region will be preserved.

– All foreground pixels which can not be reached by the structuring element without lapping over the edge of the foreground object will be eroded away!

• Opening is idempotent: Repeated application has no further effects!

Page 73: Lecture Two for teens. Introduction to Morphological Operators.

Opening

• Structuring element: 3x3 square

Page 74: Lecture Two for teens. Introduction to Morphological Operators.

Opening Example

• Opening with a 11 pixel diameter disc

Page 75: Lecture Two for teens. Introduction to Morphological Operators.

Opening Example

• 3x9 and 9x3 Structuring Element

3*9

9*3

Page 76: Lecture Two for teens. Introduction to Morphological Operators.

Opening on Gray Value Images

• 5x5 square structuring element

Page 77: Lecture Two for teens. Introduction to Morphological Operators.

Use Opening for Separating Blobs

• Use large structuring element that fits into the big blobs

• Structuring Element: 11 pixel disc

Page 78: Lecture Two for teens. Introduction to Morphological Operators.

CLOSINGCLOSING

Page 79: Lecture Two for teens. Introduction to Morphological Operators.

Closing

• Similar to Dilation– Removal of holes– Tends to enlarge regions, shrink background

• Closing is defined as a Dilatation, followed by an Erosion using the same structuring element for both operations.

• Dilation next erosion!• Input:

– Binary Image– Structuring Element, containing only 1s!

Page 80: Lecture Two for teens. Introduction to Morphological Operators.

Closing

• Take the structuring element (SE) and slide it around outside each foreground region. – All background pixels which can be covered by the SE

with the SE being entirely within the background region will be preserved.

– All background pixels which can not be reached by the structuring element without lapping over the edge of the foreground object will be turned into a foreground.

• Opening is idempotent: Repeated application has no further effects!

Page 81: Lecture Two for teens. Introduction to Morphological Operators.

Closing

• Structuring element: 3x3 square

Page 82: Lecture Two for teens. Introduction to Morphological Operators.

Closing Example

• Closing operation with a 22 pixel disc

• Closes small holes in the foreground

Page 83: Lecture Two for teens. Introduction to Morphological Operators.

Closing Example 1

1. Threshold

2. Closing with disc of size 20

Thresholded closed

Page 84: Lecture Two for teens. Introduction to Morphological Operators.

Closing Example 2

• Good for further processing: E.g. Skeleton operation looks better for closed image!

skeleton of Thresholdedskeleton of Thresholded and next closed

Page 85: Lecture Two for teens. Introduction to Morphological Operators.

Closing Gray Value Images

• 5x5 square structuring element

Page 86: Lecture Two for teens. Introduction to Morphological Operators.

Opening & Closing

• Opening is the dual of closing

• i.e. opening the foreground pixels with a particular structuring element

• is equivalent to closing the background pixels with the same element.

Page 87: Lecture Two for teens. Introduction to Morphological Operators.

Morphological Opening and Closing

• Opening of A by B A BErosion of A by B, followed bythe dilation of the result by B

Closing of A by B A B Dilation of A by B, followed bythe erosion of the result by B

MATLAB: imopen(A, B) imclose(A,B)

Page 88: Lecture Two for teens. Introduction to Morphological Operators.

MATLAB Function strel

• strel constructs structuring elements with various shapes and sizes

• Syntax: se = strel(shape, parameters)

• Example:– se = strel(‘octagon’, R);– R is the dimension – see help function

Page 89: Lecture Two for teens. Introduction to Morphological Operators.

• Opening of A by B A BErosion of A by B, followed by the dilation of the result by B

Erosion- if any element of structuring element overlaps with background output is zero

FIRST - EROSION>> se = strel('square', 20);fe = imerode(f,se);figure, imagesc(fe),title('fe')

Page 90: Lecture Two for teens. Introduction to Morphological Operators.

Dilation of Previous ResultDilation of Previous ResultOutputs 1 at center of SE when at least one element of SE overlaps object

SECOND - DILATION

>> se = strel('square', 20);fd = imdilate(fe,se);figure, imagesc(fd),title('fd')

Page 91: Lecture Two for teens. Introduction to Morphological Operators.

FO=imopen(f,se); figure, imagesc(FO),title('FO')

Page 92: Lecture Two for teens. Introduction to Morphological Operators.

What if we increased size of SE for DILATION operation??

se = strel('square', 25);fd = imdilate(fe,se);figure, imagesc(fd),title('fd')se = strel('square', 30);fd = imdilate(fe,se);figure, imagesc(fd),title('fd')

se = 25 se = 30

Page 93: Lecture Two for teens. Introduction to Morphological Operators.

Closing of A by B A B Dilation of A by B

se = strel('square', 20);fd = imdilate(f,se);figure, imagesc(fd),title('fd')

Outputs 1 at center of SE when at least one element of SE overlaps object

Page 94: Lecture Two for teens. Introduction to Morphological Operators.

Erosion of the result by BErosion of the result by BErosion- if any element of structuring element overlaps with background output is zero

Page 95: Lecture Two for teens. Introduction to Morphological Operators.

ORIGINAL

OPENING CLOSING

Page 96: Lecture Two for teens. Introduction to Morphological Operators.

Fingerprint problemFingerprint problem

From: Digital Image Processing, Gonzalez,Woods And Eddins

Page 97: Lecture Two for teens. Introduction to Morphological Operators.

HIT and HIT and MISSMISS

Page 98: Lecture Two for teens. Introduction to Morphological Operators.

Hit or Miss TransformationHit or Miss Transformation

• “Hit or Miss” Called also “Hit and Miss” is useful to identify specified configuration of pixels.

• For instance, such combinations as:– isolated foreground pixels – or pixels at end of lines (end points)

• A B = (A B1B1) (Ac B2B2)– A eroded by B1, intersection A complement eroded

by B2 (two different structuring elements)

Page 99: Lecture Two for teens. Introduction to Morphological Operators.

Hit or Miss Example: Hit or Miss Example: Find cross Find cross shape pixel configurationshape pixel configuration

0 1 0

1 1 1

0 1 0

MATLAB Function: C = bwhitmissbwhitmiss(A, B1, B2)

Page 100: Lecture Two for teens. Introduction to Morphological Operators.

Original Image A and B1

A eroded by B1

Complement of OriginalImage and B2

Erosion of A complementAnd B2

Intersection of eroded imagesFrom: Digital Image Processing, Gonzalez,Woods And Eddins

Page 101: Lecture Two for teens. Introduction to Morphological Operators.

Hit or Miss

• Have all the pixels in B1, but none of the pixels in B2

Page 102: Lecture Two for teens. Introduction to Morphological Operators.

Hit or Miss Example #2• Locate upper left hand corner pixels of objects

in an image

• Pixels that have east and south neighbors (Hits) and no NE, N, NW, W, SW Pixels (Misses)

B1 = B2 = 0 0 0

0 1 1

0 1 0

1 1 1

1 0 0

1 0 0

Don’tCare aboutSE

Page 103: Lecture Two for teens. Introduction to Morphological Operators.

Hit or Miss in MatlabHit or Miss in MatlabHit or Miss in MatlabHit or Miss in Matlab

G = bwhitmiss(f, B1, B2);Figure, imshow(g) From: Digital Image Processing, Gonzalez,Woods

And Eddins

Page 104: Lecture Two for teens. Introduction to Morphological Operators.

bwmorph(f, operation, n)

• Implements various morphological operations based on combinations of dilations, erosions and look up table operations.

• Example: Thinning>> f = imread(‘fingerprint_cleaned.tif’);

>> g = bwmorph(f, ‘thin’, 1);

>> g2 = bwmorph(f, ‘thin’, 2);

>> g3 = bwmorph(f, ‘thin’, Inf);

Page 105: Lecture Two for teens. Introduction to Morphological Operators.

Chapter 9Morphological Image Processing

Chapter 9Morphological Image Processing

InputFrom: Digital Image Processing, Gonzalez,Woods And Eddins

>> f = imread(‘fingerprint_cleaned.tif’);>> g = bwmorph(f, ‘thin’, 1);>> g2 = bwmorph(f, ‘thin’, 2);>> g3 = bwmorph(f, ‘thin’, Inf);

Page 106: Lecture Two for teens. Introduction to Morphological Operators.

From: Digital Image Processing, Gonzalez,Woods And Eddins

Page 107: Lecture Two for teens. Introduction to Morphological Operators.

Hit-and-miss Transform is Hit-and-miss Transform is used for “used for “Pattern MatchingPattern Matching””• Hit and Miss is used to look for particular

patterns of foreground and background pixels

• It allows a recognition of very simple objects• All other morphological operations can be

derived from it!!• Input:

– Binary Image– Structuring Element, containing 0s and 1s!!

Page 108: Lecture Two for teens. Introduction to Morphological Operators.

Example for a Hit-and-miss Structuring Element

• Contains 0s, 1s and don’t care’s.• Usually a “1” at the origin!

Page 109: Lecture Two for teens. Introduction to Morphological Operators.

Hit-and-miss Transform as pattern matching

• It is one variant of a general to Pattern Matching approach:– If foreground and background pixels in the

structuring element exactly match foreground and background pixels in the image,

– then the pixel underneath the origin of the structuring element is set to the foreground color.

Page 110: Lecture Two for teens. Introduction to Morphological Operators.

EXAMPLE:EXAMPLE: Corner Corner Detection with Hit-and-Detection with Hit-and-

miss Transformmiss Transform• Structuring Elements representing four

corners

Page 111: Lecture Two for teens. Introduction to Morphological Operators.

Corner Detection with Hit-and-miss Transform

1. Apply Hit-&-Miss with each Structuring Element

2. Use OR operation to combine the four results

Allows to describe approximate shape of an object

Page 112: Lecture Two for teens. Introduction to Morphological Operators.

Basic Basic THINNINGTHINNING

Page 113: Lecture Two for teens. Introduction to Morphological Operators.

ThinningThinning

1. Used to remove selected foreground pixels from binary images

2. After edge detection, lines are often thicker than one pixel.

3. Thinning can be used to thin those line to one pixel width.

Page 114: Lecture Two for teens. Introduction to Morphological Operators.

Definition of Thinning

• Let K be a kernel and I be an image

with 0-1=0!!• If foreground and background fit the structuring

element exactly, then the pixel at the origin of the SE is set to 0set to 0

• Note that the value of the SE at the origin is 1 or don’t care!

KIIKI ,H i t A n d M i s s,t h i n

Page 115: Lecture Two for teens. Introduction to Morphological Operators.

Example Thinning with two H&M transformsWe use two Hit-and-miss Transforms

0000

Page 116: Lecture Two for teens. Introduction to Morphological Operators.

Basic Basic THICKENINGTHICKENING

Page 117: Lecture Two for teens. Introduction to Morphological Operators.

Thickening

• Used to grow selected regions of foreground pixels

• E.g. applications like approximation of convex hull

Page 118: Lecture Two for teens. Introduction to Morphological Operators.

Definition Thickening

• Let K be a kernel and I be an image

with 1+1=1• If foreground and background match exactly the SE,

then set the pixel at its origin to 1!

• Note that the value of the SE at the origin is 0 or don’t care!

KIIKI ,H i t A n d M i s s,t h i c k e n

Page 119: Lecture Two for teens. Introduction to Morphological Operators.

Example ThickeningIf foreground and background match exactly the SE, then set the pixel at its origin to 1!

1111

Page 120: Lecture Two for teens. Introduction to Morphological Operators.

SkeletonizationSkeletonizationSkeletonizationSkeletonizationFrom: Digital Image Processing, Gonzalez,Woods And Eddins

Bone Image

Skeleton obtained using function

bwmorph

Resulting Skeleton obtained after pruning

with function endpoints

Page 121: Lecture Two for teens. Introduction to Morphological Operators.

Objects in ImagesObjects in ImagesObjects in ImagesObjects in Images

From: Digital Image Processing, Gonzalez,Woods And Eddins

Image containing ten objects

A subset of pixels from the Image

In many cases we want to find some known objects in images

Page 122: Lecture Two for teens. Introduction to Morphological Operators.

Finding objects in picturesFinding objects in picturesFinding objects in picturesFinding objects in pictures

From: Digital Image Processing, Gonzalez,Woods And Eddins

Pixel p and its 4-neighbors

Pixel p and its diagonal neighbors Pixel p and its 8- neighbors

4 and 8 adjacent pixels

Pixels that are 8 adjacent but not 4 adjacent

These pixels are 4 and 8 connected

These pixels are 8 connected but not 4 connected

Page 123: Lecture Two for teens. Introduction to Morphological Operators.

How many objects are really in a How many objects are really in a picture?picture?

How many objects are really in a How many objects are really in a picture?picture?

From: Digital Image Processing, Gonzalez,Woods And Eddins

Page 124: Lecture Two for teens. Introduction to Morphological Operators.

Connected ComponentsConnected ComponentsConnected ComponentsConnected Components

From: Digital Image Processing, Gonzalez,Woods And Eddins

Center of mass is another useful concept in object recognition

Page 125: Lecture Two for teens. Introduction to Morphological Operators.

Morphological Morphological ReconstructionReconstruction

Original image (the mask)

Marker image Intermediate image after 100 iterations

Page 126: Lecture Two for teens. Introduction to Morphological Operators.

Chapter 9Morphological Image Processing

Chapter 9Morphological Image Processing

Morphological ReconstructionMorphological Reconstruction

Page 127: Lecture Two for teens. Introduction to Morphological Operators.

Translation and ReflectionTranslation and ReflectionTranslation and ReflectionTranslation and Reflection

From: Digital Image Processing, Gonzalez,Woods And Eddins

Page 128: Lecture Two for teens. Introduction to Morphological Operators.

Reflection

• Dilation definitionDilation definition:

“Dilation of A by B is the set consisting of all structuring element origin locations where the reflected and translated B overlaps at least some portion of A”

• If structuring element is symmetric with respect to symmetric with respect to origin,origin, reflection of B has no effect

Page 129: Lecture Two for teens. Introduction to Morphological Operators.

PROBLEMS PROBLEMS TO THINKTO THINK

Page 130: Lecture Two for teens. Introduction to Morphological Operators.

Images of lanes and corridors

Page 131: Lecture Two for teens. Introduction to Morphological Operators.

Problems

1. Consider the images on slide 17! Why are the images getting darker under erosion? Explain!

2. Consider the images on slide 31! Why are the intensities becoming more uniform? Explain!

3. Compare Dilatation and Erosion! How are they related? Verify your answers with Matlab!

4. Apply Erosion and Dilatation for noise removal!

5. Consider slide 38: Remove the artefacts remaining with the horizontal lines.

Page 132: Lecture Two for teens. Introduction to Morphological Operators.

Problems

6. Derive dilatation and erosion from the Hit-and-miss transformation

7. How to use these all operations to find some good features in our FAB building corridors and halls so that the robot can recognize the object such as door or windows?

Page 133: Lecture Two for teens. Introduction to Morphological Operators.

Sources Used

1. Volker Krüger

2. Rune Andersen

3. . Roger S. Gaborski