ch9 - morphological image processing

Post on 23-Oct-2015

56 Views

Category:

Documents

9 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Morphological Image Processing

Chapter 9

Introduction

The word morphology commonly denotes a branch of biology that deals with the form and structure of animals and plants.

Therefore, morphological operations are intended to affect the shape of the object

We use mathematical morphology as a tool for extracting image components that are useful in the representation and description of region shape, such as boundaries, skeletons.

intended to affect the shape of the object

Contents

Once segmentation is complete, morphological operations can be used to remove imperfections in the segmented image and provide information on the form and structure of the imagewe will consider:

– What is morphology?– Simple morphological operations– Compound operations– Morphological algorithms

1, 0, Black, White?

Throughout all of the following slides whether 0 and 1 refer to white or black is a little interchangeableAll of the discussion that follows assumes segmentation has already taken place and that images are made up of 0s for background pixels and 1s for object pixelsAfter this it doesn’t matter if 0 is black, white, yellow, green…….

What Is Morphology?

Morphological image processing (or morphology) describes a range of image processing techniques that deal with the shape (or morphology) of features in an imageMorphological operations are typically applied to remove imperfections introduced during segmentation, and so typically operate on bi-level images

Quick Example

Image after segmentation Image after segmentation and morphological processing

Mathematic Morphology• used to extract image components that are useful in

the representation and description of region shape, such as – boundaries extraction– boundaries extraction– skeletons– convex hull– morphological filtering– thinning– pruning

Mathematic Morphology

mathematical framework used for:• pre-processing

– noise filtering, shape simplification, ...• enhancing object structure• enhancing object structure

– skeletonization, convex hull...• Segmentation

– watershed,…• quantitative description

– area, perimeter, ...

Basic Set Theory

Z2 and Z3

• set in mathematic morphology represent objects in an image– binary image (0 = white, 1 = black) : the element – 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 the coordinates (x,y) of pixel belong to the object and the gray levels � Z3

Structuring element (SE)

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

the origo is the reference point on which deictic relationships are based.

Structuring Elements, Hits & Fits

B Structuring Element

Fit: All on pixels in the structuring element cover on

AC

structuring element cover on pixels in the imageHit: Any on pixel in the structuring element covers an on pixel in the image

All morphological processing operations are based on these simple ideas

Reflection and Translation

} ,|{ˆ Bfor bbwwB ∈−∈=

} ,|{)( Afor azaccA z ∈+∈= } ,|{)( Afor azaccA z ∈+∈=

Logic Operations

Example:

Basic idea

• in parallel for each pixel in binary image:– check if SE is ”satisfied”– output pixel is set to 0 or 1 depending on used

operationoperation

Fundamental Operations

Fundamentally morphological image processing is very like spatial filteringThe structuring element is moved across every pixel in the original image to give a pixel in a new processed imageThe value of this new pixel depends on the operation performedThere are two basic morphological operations: erosion and dilation

Basic morphological operations

• Erosion

• Dilation• Dilation

• combine to– Opening object

– Closening background

keep general shape but smooth with respect to

Erosion• Erosion is one of the two basic operators in the area of mathematical morphology , the other being dilation.

• It is typically applied to binary image, but there are versions that work on gray scale image. are versions that work on gray scale image.

• The basic effect of the operator on a binary image is to erode away the boundaries of regions of foreground pixels (i.e. white pixels, typically).

• Thus areas of foreground pixels shrink in size, and holes within those areas become larger.

Erosion

Erosion of image f by structuring element s is given by f � sThe structuring element s is positioned with its origin at (x, y) and the new pixel value is determined using the rule:

=otherwise 0

fits if 1),(

fsyxg

Erosion:

• Does the structuring element fit the set?erosion of a set A by structuring element B: all z

in A such that B is in A when origin of B=zin A such that B is in A when origin of B=z

shrink the object

}{ Az|(B)BA z ⊆=−

Erosion

Erosion

}Az|(B){BA z ⊆=−

Effect of erosion using a 3×3 square structuring element

Applications of erosion : Eliminating unwanted detail in an image

Erosion : eliminating irrelevant detail

structuring element B = 13x13 pixels of gray level 1

Erosion Application Example 1

Watch out: In these examples a 1 refers to a black pixel!

Original image Erosion by 3*3 square structuring

element

Erosion by 5*5 square structuring element

Erosion Application Example 2

Original image

After erosion with a disc of radius 10

After erosion with a disc of radius 20

After erosion with a disc of

radius 5

What Is Erosion For?

Erosion can split apart joined objects

Erosion can split apart

Erosion can strip away extrusions

Watch out: Erosion shrinks objects

Erosion can split apart

Erosion, matlab exampleoriginalBW = imread('circles.png'); se = strel('disk',11); erodedBW = imerode(originalBW,se);imshow(originalBW), figure, imshow(erodedBW)

Dilation• Dilation is one of the two basic operators in the area of mathematical morphology , the other being erosion.

• It is typically applied to binary image, but there are versions that work on gray scale image.

• The basic effect of the operator on a binary image is to gradually enlarge the boundaries of regions of foreground pixels (i.e. white pixels, typically).

• Thus areas of foreground pixels grow in sizewhile holes within those regions become smaller.

DilationDilation of image f by structuring element s is given by f sThe structuring element s is positioned with its origin at (x, y) and the new pixel value is

determined using the rule:

=otherwise 0

hits if 1),(

fsyxg

Dilation:

• Does the structuring element hit the set?• dilation of a set A by structuring element B: all z

in A such that B hits A when origin of B=zin A such that B hits A when origin of B=z

• grow the object

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

Dilation

Dilation

Dilation

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

B = structuring element

Effect of dilation using a 3×3 square structuring element

Applications of dilaion : For bridging gaps in an image

An example:

Dilation Example 1

Original image Dilation by 3*3 square structuring

element

Dilation by 5*5 square structuring element

Watch out: In these examples a 1 refers to a black pixel!

Dilation : Bridging gaps

Dilation, matlab examplebw = imread('text.png');se = strel('line',11,90);bw2 = imdilate(bw,se);imshow(bw), title('Original')figure, imshow(bw2), title('Dilated'

useful

• Erosion– removal of structures of certain shape and size,

given by SEgiven by SE• Dilation

– filling of holes of certain shape and size, given by SE

Combining erosion and dilation

• WANTED:– remove structures / fill holes– without affecting remaining parts– without affecting remaining parts

• SOLUTION:• combine erosion and dilation• (using same SE)

Duality

−=⊕ BA)BA( cc

⊕=− BABA c

−=⊕ BA)BA( cc

Compound Operations

More interesting morphological operations can be performed by performing combinations of erosions and dilationsThe most widely used of these compound operations are:

– Opening

– Closing B)BA(BA

B)BA(BA

−⊕=•

⊕−=o

Opening and Closing

· Opening and Closing are morphological operations which are based on dilation and erosion.

· Opening smoothes the contours of objects, breaks narrow isthmuses and eliminates thin breaks narrow isthmuses and eliminates thin protrusions.

· Closing also produces the smoothing of sections of contours but fuses narrow breaks, fills gaps in the contour and eliminates small holes.

· Opening is basically erosion followed by dilationwhile closing is dilation followed by erosion.

How OpeningWorks ?· An opening is defined as an erosion followed by a dilationusing the same structuring element for both operations.

Effect of opening using a 3×3 square structuring element

Opening Operation Opening Operation

BBABA ⊕= ) (o

( ) ( ){ }ABBBA zz ⊆∪=o

or

= Combination of all parts of A that can completely contain B

(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.

Opening eliminates narrow and small details and corners.

Opening effectOriginal Image Processed Image

Structuring Element

Opening example 2

Opening Operation: application

Structuring element is an 11pixel array with a circle shape

Input Image Resultant Image

Opening Operation, matlab example• I = imread('snowflakes.png');figure; imshow(I)

• BW = IM2BW(I); figure; imshow(BW)

• se = strel('disk',3);• I_opened = imopen(BW ,se);• figure, imshow(I_opened)

How Closing Works?

· Grey level closing consists straightforwardly of a grey level dilation followed by a grey level erosion.

· The closing operator therefore requires two inputs: an image to be closed, and a structuring element.

Effect of closing using a 3×3 square structuring element

Closing effectOriginal Image Processed Image

Structuring Element

Closing Operation Closing Operation

BBBA )A( ⊕=•

(Images from Rafael C. Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.

Closing fills narrow gaps and notches

Closing example 2:

Application

Structure element is in between the smaller circle and large circle

Closing Operation, matlab example

• originalBW = imread('circles.png');• imshow(originalBW);

• se = strel('disk',10);• closeBW = imclose(originalBW,se);• figure, imshow(closeBW)

Example: Application of Morphological OperationsExample: Application of Morphological Operations

Finger print enhancement

(Images from Rafael C.Gonzalez and Richard E. Wood, Digital Image Processing, 2nd Edition.

Duality Between Opening and ClosingDuality Between Opening and Closing

( ) ( )BABA cc ˆo=•

Properties OpeningProperties Opening

( )BDBCDC

ABA

oo

o

=

⊂⊂

then If 2.

.1

( ) BABBA ooo = .3

( ) BABBA

BDBCDC

BAA

•=••

•⊂•⊂

•⊆

.3

then If 2.

.1Properties ClosingProperties Closing

Idem potent property: can’t change any more

Hit or Miss Transform

Basic operation where all other operatorscan be derived

It Hit or miss transform of A by B is denoted by

A B

The difference is in structure element from others

*

HitHit--oror--Miss Transformation Miss Transformation

where X = shape to be detectedW = window that can contain X

( ) [ ])XW( AX AB A c −∩=* ∩

HitHit--oror--Miss Transformation (cont.) Miss Transformation (cont.)

( ) [ ])XW( AX AB A c −∩=* ∩

• How It Works ?

• The structural elements used for Hit-or-miss transforms are an extension to the ones used with dilation, erosion etc.

• The structural elements can contain both foreground and background pixels, rather than just foreground pixels, i.e. both ones and zeros.

• The structuring element is superimposed over each pixel in the • The structuring element is superimposed over each pixel in the input image, and if an exact match is found between the foreground and background pixels in the structuring element and the image, the input pixel lying below the origin of the structuring element is set to the foreground pixel value. If it does not match, the input pixel is replaced by the background pixel value.

Structuring elements

Example

Boundary Extraction Boundary Extraction

( )BAAβ(A) −=

Original image

Boundary

Region (Hole) Filling Region (Hole) Filling

( ) ckk ABXX ∩⊕= −1

where X0 = seed pixel p

∩ k = 1, 2, 3, …..

The iteration stops at step k if Xk = Xk-1

Original image

Results of region filling

p

Extraction of Connected Components Extraction of Connected Components

( ) ABXX kk ∩⊕= −1

The iteration stops at step k if Xk = Xk-1

∩ k = 1, 2, 3, …..

where X0 = seed pixel p

Example: Extraction of Connected Components Example: Extraction of Connected Components

X-ray imageof bones

ThresholdedThresholdedimage

Connectedcomponents

Convex Hull Convex Hull

Convex hull has no concave part.

Convex hull

i

i

DAC ∪=

=4

1

)(

( ) 4,3,2,1 , 1 =∪= − iABXX ik

ik *

iconv

i XD =Algorithm: where

Example: Convex Hull Example: Convex Hull

Thinning Thinning

cBAA

BAABA

) (

) (

∩=

−=⊗ *

*

{ } ))...))((...(( 21 nBBBABA ⊗⊗⊗=⊗

Example: Thinning Example: Thinning

Make an object thinner.

Thickening Thickening

* ) ( BAABA ∪=.

{ } ) )...) ) ((...(( 21 nBBBABA =. . . .*

Make an object thicker

Skeletons Skeletons

Dot lines are skeletons of thisstructurestructure

Skeletons (cont.) Skeletons (cont.)

)()(0

ASAS k

K

k∪=

=

with BkB)AkB)AASk o ( ()( −=

where ...) ) ) (...( ( BBBAkB)A =

k times

and ( ){ }φ≠= kBAkK max

Skeletons Skeletons

Pruning Pruning

{ }BAX ⊗=1

AHXX ∩⊕= )( 23

) ( 1

8

12

k

k

BXX ∪=

= *

= thinning

= finding end points

= dilation at end points

314 XXX ∪= = Pruned result

Example: Pruning Example: Pruning

Originalimage

After Thinning End

Prunedresult

Thinning3 times

End points

Dilationof end points

Summary of Binary Morphological Operations Summary of Binary Morphological Operations

Summary of Binary Morphological Operations (cont.) Summary of Binary Morphological Operations (cont.)

Summary of Binary Morphological Operations (cont.) Summary of Binary Morphological Operations (cont.)

Summary of Binary Morphological Operations (cont.) Summary of Binary Morphological Operations (cont.)

Basic Types of Structuring ElementsBasic Types of Structuring Elements

x = don’t care

GrayGray--Scale Dilation Scale Dilation

{ }bf DyxDytxsyxbytxsfbf ∈∈−−+−−=⊕ ),(;)(),(|),(),(max

{ }bf DxDxsxbxsfbf ∈∈−+−=⊕ and )(|)()(max2-D Case

1-D Case

SubimageOriginal image

Moving

Max

GrayGray--Scale Dilation (cont.) Scale Dilation (cont.)

+

Reflectionof B

window

Output image

Structuring element B

Note: B can be any shape and subimage must have the same shape asreflection of B.

GrayGray--Scale ErosionScale Erosion

{ }bf DyxDytxsyxbytxsfbf ∈∈++−++=− ),(;)(),(|),(),(min2-D Case

1-D Case { }bf DxDxsxbxsfbf ∈∈+−+=− and )(|)()(min

SubimageOriginal image

Moving

Min

GrayGray--Scale Erosion (cont.) Scale Erosion (cont.)

-B

Moving window

Output image

Structuring element B

Note: B can be any shape and subimage must have the same shape as B.

Example: GrayExample: Gray--Scale Dilation and ErosionScale Dilation and ErosionOriginal image After dilation

After erosion

Darker Brighter

GrayGray--Scale OpeningScale Opening

bbfbf ⊕−= )(o

Opening cuts peaks

GrayGray--Scale ClosingScale Closing

bbfbf −⊕=• )(

Closing fills valleys

Example: GrayExample: Gray--Scale Opening and ClosingScale Opening and Closing

Original image After closingAfter opening

Reduce whiteobjects

Reduce darkobjects

GrayGray--scale Morphological Smoothing scale Morphological Smoothing

Smoothing: Perform opening followed by closing

Original image After smoothing

Morphological Gradient Morphological Gradient

)()( bfbfg −−⊕=

Original image Morphological Gradient

TopTop--Hat Transformation Hat Transformation

)( bffh o−=

Original image Results of top-hat transform

Example: Texture Segmentation Application Example: Texture Segmentation Application

Small blob

Algorithm:1. Perform closing on the image by using successively larger structuring elements until small blobs are vanished.2. Perform opening to join large blobs together3. Perform intensity thresholding

Original image Segmented result

Large blob

Example: Granulometry Example: Granulometry Objective: to count the number of particles of each sizeMethod:1. Perform opening using structuring elements of increasing size2. Compute the difference between the original image and the result

after each opening operation3. The differenced image obtained in Step 2 are normalized and used

to construct the size-distribution graph.

Original imageSize distribution

graph

top related