Вы находитесь на странице: 1из 96

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.

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 image we 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 interchangeable All 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 pixels After this it doesnt 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 image Morphological operations are typically applied to remove imperfections introduced during segmentation, and so typically operate on bilevel 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 skeletons convex hull morphological filtering thinning pruning

Mathematic Morphology
mathematical framework used for: pre-processing noise filtering, shape simplification, ... 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 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 properties 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 pixels in the image Hit: Any on pixel in the structuring element covers an on pixel in the image

A C

All morphological processing operations are based on these simple ideas

Reflection and Translation

= {w | w b, for b B} B
( A) z = {c | c a + z , for a A}

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 operation

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

Basic morphological operations


Erosion Dilation combine to
Opening Closening
keep general shape but smooth with respect to

object background

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. 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 s The structuring element s is positioned with its origin at (x, y) and the new pixel value is determined using the rule:

1 if s fits f g ( x, y ) = 0 otherwise

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

A B = {z|(B)z A}
shrink the object

Erosion

Erosion

A B = { z|(B)z A }

Effect of erosion using a 33 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

Original image

Erosion by 3*3 square structuring element

Erosion by 5*5 square structuring element

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

Erosion Application Example 2

Original image

After erosion with a disc of radius 10

After erosion with a disc of radius 5

After erosion with a disc of radius 20

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, matlab example


originalBW = 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 size while holes within those regions become smaller.

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

1 if s hits f g ( x, y ) = 0 otherwise

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

) A B = { z|( B z A }
grow the object

Dilation

Dilation

Dilation

B = structuring element

) A B = {z|(B z A }

Effect of dilation using a 33 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 example


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

SOLUTION: combine erosion and dilation (using same SE)

Duality

A B = A B

( A B ) = A B

Compound Operations
More interesting morphological operations can be performed by performing combinations of erosions and dilations The most widely used of these compound operations are:
Opening Closing

Ao B = ( A B ) B A B = ( A B ) B

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 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 dilation while closing is dilation followed by erosion.

How Opening Works ?


An opening is defined as an erosion followed by a dilation using the same structuring element for both operations.

Effect of opening using a 33 square structuring element

Opening Operation or

A o B = ( A B) B
A o B = {(B )z (B )z A}

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

Opening eliminates narrow and small details and corners.


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

Opening effect
Original 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?


The closing operator therefore requires two inputs: an image to be closed, and a structuring element. Grey level closing consists straightforwardly of a grey level dilation followed by a grey level erosion.

Effect of closing using a 33 square structuring element

Closing effect
Original Image Processed Image

Structuring Element

Closing Operation

A B = (A B)

Closing fills narrow gaps and notches

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

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 Operations Finger print enhancement

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

Duality Between Opening and Closing

(A B)
Properties Opening

= Ac o B

1. A o B A 2. If C D then C o B D o B 3. ( A o B ) o B = A o B
Properties Closing

1. A A B 2. If C D then C B D B 3. ( A B ) B = A B
Idem potent property: cant change any more

Hit or Miss Transform


Basic operation where all other operators can 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

A * B = (A

X ) Ac

(W X )

where X = shape to be detected W = window that can contain X

HitHit -oror-Miss Transformation (cont.)

A * B = (A

X ) Ac

(W X )

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

Example

Structuring elements

Boundary Extraction

(A) = A ( A

B)

Original image

Boundary

Region (Hole) Filling


Ac X k = ( X k 1 B )
k = 1, 2, 3, ..

where X0 = seed pixel p The iteration stops at step k if Xk = Xk-1

Original image

Results of region filling

Extraction of Connected Components

X k = ( X k 1 B ) A

k = 1, 2, 3, ..

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

where X0 = seed pixel p

Example: Extraction of Connected Components X-ray image of bones

Thresholded image

Connected components

Convex Hull Convex hull has no concave part. Convex hull

Algorithm:

C ( A) = D
i =1

where

i D i = X conv

X ki = (X k 1 * B i ) A,

i = 1,2,3,4

Example: Convex Hull

Thinning

A B = A ( A * B) = A ( A * B )c A {B} = ((...(( A B1 ) B 2 )...) B n )

Example: Thinning

Make an object thinner.

Thickening

. A B = A ( A * B) . . . . A {B} = ((...(( A B ) B )...) B )


1 2 n

Make an object thicker

Skeletons

Dot lines are skeletons of this structure

Skeletons (cont.)
K

S ( A) = Sk ( A)
k =0

with

Sk ( A) = ( A

kB) ( A

kB) o B

where ( A

kB) = (...( A B ) B ) ...)


k times

and

K = max{k ( A

kB ) }

Skeletons

Pruning

X 1 = A {B}
8 k =1

= thinning

X 2 = ( X 1 * B k ) = finding end points X 3 = ( X 2 H ) A = dilation at end points X 4 = X 1 X 3 = Pruned result

Example: Pruning

Original image After Thinning 3 times Dilation of end points

End points

Pruned result

Summary of Binary Morphological Operations

Summary of Binary Morphological Operations (cont.)

Summary of Binary Morphological Operations (cont.)

Summary of Binary Morphological Operations (cont.)

Basic Types of Structuring Elements

x = dont care

GrayGray -Scale Dilation


1-D Case 2-D Case
f b = max{f ( s x ) + b( x ) | ( s x ) D f and x Db }

f b = max{f ( s x, t y ) + b( x, y ) | ( s x ), (t y ) D f ; ( x, y ) Db }

GrayGray -Scale Dilation (cont.)


Original image Subimage Reflection of B

+
Max Moving window Structuring element B Note: B can be any shape and subimage must have the same shape as reflection of B.

Output image

GrayGray -Scale Erosion


1-D Case
f b = min{f ( s + x ) b( x ) | ( s + x ) D f and x Db }

2-D Case f b = min{f ( s + x, t + y ) b( x, y ) | ( s + x ), (t + y ) D f ; ( x, y ) Db }

GrayGray -Scale Erosion (cont.)


Original image Subimage B

Min Moving window Structuring element B Note: B can be any shape and subimage must have the same shape as B. Output image

Example: GrayGray-Scale Dilation and Erosion


Original image After dilation

Darker

Brighter

After erosion

GrayGray -Scale Opening

f o b = ( f b) b

Opening cuts peaks

GrayGray -Scale Closing

f b = ( f b) b

Closing fills valleys

Example: GrayGray-Scale Opening and Closing

Original image

After opening

After closing

Reduce white objects

Reduce dark objects

GrayGray -scale Morphological Smoothing Smoothing: Perform opening followed by closing

Original image

After smoothing

Morphological Gradient

g = ( f b) ( f b)

Original image

Morphological Gradient

TopTop -Hat Transformation

h = f ( f o b)

Original image

Results of top-hat transform

Example: Texture Segmentation Application

Small blob Original image Segmented result Large 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 together 3. Perform intensity thresholding

Example: Granulometry
Objective: to count the number of particles of each size Method: 1. Perform opening using structuring elements of increasing size 2. Compute the difference between the original image and the result after each opening operation 3. The differenced image obtained in Step 2 are normalized and used to construct the size-distribution graph.

Original image

Size distribution graph

Вам также может понравиться