Sie sind auf Seite 1von 72

1

of
39

IMAGE PROCESSING

MORPHOLOGICAL IMAGE
PROCESSING
2
of
39
Introduction
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

Morphology is the science of appearance, shape and


organization.

Mathematical morphology is a collection of non-linear


processes which can be applied to an image to
remove details smaller than certain reference shape.
3
of
39
1, 0, Black, White?
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

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 bi-level images
4
of
39
Quick Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Image after segmentation Image after segmentation and


morphological processing
5
of
39
Structuring Elements, Hits & Fits

B Structuring Element

Fit: All on pixels in the


structuring element cover
on pixels in the image
A
Hit: Any on pixel in the
C structuring element covers
an on pixel in the image

All morphological processing operations are based


on these simple ideas
6
of
39
Structuring Elements
Structuring elements (SE) can be of any size and
make any shape
However, for simplicity we will transform SE
irrespective of its shape to rectangular structuring
elements with their origin at the middle pixel

0 0 1 0 0
1 1 1 0 1 0 0 1 1 1 0
1 1 1 1 1 1 1 1 1 1 1
1 1 1 0 1 0 0 1 1 1 0
0 0 1 0 0
7
of Fundamental Definitions
39
The object A consists of those pixels a that share some
common property:

Object -

The background of A is given by Ac (the complement of A)


which is defined as those elements that are not in A:
Background -
8
of
39
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
9
of
39
Erosion
With A& B as sets in Z2 , erosion of image A by
structuring element B is given by A B

OR

Erosion of A by B is the set of all points z, such that


B, translated by z, is contained in A or B not sharing
any common elements with the background.
AC is the complement of A & is the empty set
10
of
39
Erosion
Erosion shrinks image
The structuring image is normally smaller than the image
This ensures faster computation
The process moves the SE from left to right and top to
bottom. At the centre position, indicated by centre of
structuring element, the process will look for whether there
is complete overlap of SE with the image or not.

ie. If the structuring element s is positioned with its origin at


(x, y) of image f , the new pixel value is determined using
the rule:
11
of
39
Erosion Example
Original Image Processed Image With Eroded Pixels

Structuring Element
12
of
39
Erosion Example
Original Image Processed Image

Structuring Element
13
of
39
Pictorial representation of Erosion
14
of
39
Erosion Example 1

Original image Erosion by 3*3 Erosion by 5*5


square structuring square structuring
element element

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


15
of
39
Erosion Example 2
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

After erosion
Original
with a disc of
image
radius 10

After erosion After erosion


with a disc of with a disc of
radius 5 radius 20
16
of
39
What Is Erosion For?
Erosion can split apart joined objects

Erosion can split apart

Erosion can strip away extrusions

Watch out: Erosion shrinks objects


17
of
39
Dilation
Dilation of image A by structuring element B is
given by A B

OR

Dilation of A by B is the set of all points z, such


that B & A overlap by at least one element

18
of
39
Dilation
Thickens objects in a binary image
Process in which the binary image is expanded from its
original shape. Similar to convolution process.
The SE is reflected and shifted from left to right and top to
bottom. At the centre position, indicated by centre of
structuring element, the process will look for whether there
is overlap of at least one element in the image with the SE
or not.

If the structuring element s is positioned with its origin at


(x, y) of image f , the new pixel value is determined using
the rule:
at least by one element
19
of
39
Dilation Example
Original Image Processed Image

Structuring Element
20
of
39
Dilation Example
Original Image Processed Image With Dilated Pixels

Structuring Element
21
of
39
Pictorial representation of Dilation
22
of
39
Dilation Example 1

Original image Dilation by 3*3 Dilation by 5*5


square structuring square structuring
element element

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


23
of
39
Dilation Example 2
Original image After dilation

Structuring element
24
of
39
What Is Dilation For?
Dilation can repair breaks

Dilation can repair intrusions

Watch out: Dilation enlarges objects


25
of
39
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
26
of
39
Opening
The opening of image A by structuring
element B, denoted A B is simply an erosion

followed by a dilation
A B = (AB) B OR

Original shape After erosion After dilation


(opening)

Note: Here a disc shaped structuring element is used


27
of
39
Opening Example

Original
Image

Image
After
Opening
28
of
39
Opening Example
29
of
39
Opening Example
Original Image Processed Image

Structuring Element
30
of
39
Opening Example
Original Image Processed Image

Structuring Element
31
of
39
Closing
The closing of image A by structuring
element B, denoted A B is simply a dilation
followed by an erosion
A B = (A B ) B

Original shape After dilation After erosion


(closing)

Note : a disc shaped structuring element is used


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

of
39
32

After
Image
Image
Original

Closing
Closing Example
33
of
39
Closing Example
Closing Example
34
of
39
Closing Example
Original Image Processed Image

Structuring Element
35
of
39
Closing Example
Original Image Processed Image

Structuring Element
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

of
39
36
Morphological Processing Example
37
of
39
Duality of Erosion & Dilation
38
of
39
Morphological Algorithms
Using the simple technique we have looked
at so far we can begin to consider some
more interesting morphological algorithms
We will look at:
- Hit / Miss algorithm
Boundary Detection
Hole filling
Convex Hull
Thinning/thickening
Pruning
39
of
39
Hit/Miss transform
The hit-and-miss transform is a general binary
morphological operation that can be used to look
for particular patterns of foreground and
background pixels in an image.

It is actually the basic operation of binary


morphology since almost all the other binary
morphological operators can be derived from it.

As with other binary morphological operators it


takes as input abinary imageand a
structuring element, and produces another binary
image as output.
40
of
39
Hit/Miss transform
The hit-and-miss operation is performed in much the
same way as other morphological operators, by
translating the origin of the structuring element to all
points in the image, and then comparing the structuring
element with the underlying image pixels.

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

If it doesn't match, then that pixel is set to the


background color.
41
of
Pictorial representation of Hit/Miss
39
transformation
42
of
39
Hit/Miss transform
Let the origin of each shape be located at its center of
gravity.
If we want to find the location of a shape , say X ,
at (larger) image, say A :
Let X be enclosed by a small window, say W.
The local background of X with respect to W is
defined as the set difference (W - X).
Apply erosion operator of A by X, will get us the set of
locations of the origin of X, such that X is completely
contained in A.
It may be also view geometrically as the set of all
locations of the origin of X at which X found a match
(hit) in A.
43
of
39
Hit/Miss transform
Cont.
Apply erosion operator on the complement of A by the
local background set (W X).
Notice, that the set of locations for which X exactly
fits inside A is the intersection of these two last
operators above.
This intersection is precisely the location sought.
Formally:
The hit or miss transformation is the intersection of the
erosion of the foreground with X and erosion of the
background with (W-X)

A
B ( AOX ) A O(W X )
c

44
of
39
Boundary Extraction
Extracting the boundary (or outline) of an object is often
extremely useful
The boundary of a set A can be given simply as
(A) = A (AB)
where B is the suitable SE
45
of
39
Boundary Extraction Example
A simple image and the result of performing
boundary extraction using a square 3*3
structuring element

Original Image Extracted Boundary


46
of
39
Hole/Region Filling
Given a pixel inside a boundary, hole filling
attempts to fill that boundary with object
pixels (1s)

Given a point inside


the hole, can we fill
the whole circle?
47
of
39
Region Filling (cont)
The key equation for region filling is

X k ( X k 1 B ) A c
k 1,2,3.....
We begin by forming an array X0 as the starting
point inside the boundary. B is a simple structuring
element and Ac is the complement of A
This equation is applied repeatedly until X k= Xk-1

Finally, set union of the results (all X k) & A contains


all the filled holes & their boundaries
48
of
Pictorial representation of Region
39
filling
49
of
39
Region Filling Step By Step
50
of
39
Region Filling Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Original Image One Region All Regions


Filled Filled
Convex Hull
51
of
39

A set A is said to be convex if the straight


line segment joining any two points in A lies
entirely within A.

The convex hull H of an arbitrary set S is the


smallest convex set containing S.

The difference H S is called the convex


deficiency of S.

The convex hull and convex deficiency are


52
of
39
Convex Hull
Algorithm for obtaining convex hull C(A) of a set A
53
of
39
54
of
39
Convex Hull
55
of
39
Convex Hull
One shortcoming of the procedure is that the convex hull
can grow beyond the minimum dimensions required to
guarantee convexity.
One simple approach to reduce this effect is to limit
growth such that it does not extend past the vertical and
horizontal dimensions of the original set.
56
of
39
Thinning / Thickening
Thinning is an image-processing operation in which
binary valued image regions are reduced to lines
The purpose of thinning is to reduce the image
components to their essential information for further
analysis and recognition

Thickening is changing a pixel from 1 to 0 if any


neighbors of the pixel are 1.

Thickening followed by thinning can be used for filling


undesirable holes.
Thinning followed by thickening is used for determining
isolated components and clusters.
57
of
39 Thinning
Thinning is defined in terms of hit or miss
transform as

where B is a sequence of structuring


elements like {B} = {B1 , B2 , B3 , , B n }
and the operation can also be given as
58
of
39 Thinning
59
of
39 Thickening
Thickening is the morphological dual of thinning
and defined as

where B is a structuring element suitable for thickening.

As in thinning, thickening can be defined as a


sequentional operation:
60
of
39 Thickening
The structuring element used for thickening has
the same form as one used for thinning but with
all ones and zeros interchanged.

However, the usual procedure is to thin the


background of the set to be processed and then
complement the result. Therefore, to thicken a
set A, we form its complement, thin it, and then
complement the result.
61
of
39 Thickening
62
of
39
Pruning
Pruning methods are an essential component to thinning
and skeletonizing algorithms since these procedures
tend to leave parasitic components that need to be
cleaned up by post-processing.

We start with a pruning problem and then develop a


morphological solution.

A common approach in the automated recognition of


printed characters is to analyze the shape of the
skeleton of each character. These skeletons often are
characterized by spurs (parasitic components).
63
of
39
Pruning

Spurs are created during the erosion by non uniformities


in the strokes composing the characters.

We develop a morphological technique for handling this


problem, starting with the assumption that the length of a
parasitic component does not exceed a specific number
of pixels.

The solution is based on suppressing a parasitic branch


by successively eliminating its end point. This also
shortens (or eliminates) other branches in the character.
64
of
39
Pruning
The assumption is that, in the absence of other
structural information, any branch with 3 or less
pixels should be eliminated.

Thinning of an input set A with a sequence of


structuring elements designed to detect only end
points achieves the desired result.
65
of
39
Pruning
The following steps are used for pruning:
Thinning

Restore to original form with end points removed

Dilate end points

Find the union of X1 and X3


66
of
39
Pruning
67
of
39
Pruning
Let

where {B} is the sequence of structuring elements. This


sequence consists of two different structures, each of which is
rotated 90degree for a total of 8 elements.
Applying the equation 3 times yields the set X1 and the
next step is to restore the character to its original form but
with the parasitic branches removed.

To do this, we first form a set X2 containing all end points


in X1:

Bk are the same structuring elements / end point detectors.


68
of
39
Pruning
Next step is dilation of the end points 3 times using set A
as a delimiter:

H is a 3x3 structuring element of ones and the intersection with


A as applied after each step.
This type of conditional dilation prevents appearance of non-
zero elements outside the region of interest.

Finally, the union of X3 and X1 yields the desired result:


69
of
39
Summary (1)

05/14/17 69
70
of
39
Summary (2)

05/14/17 70
71
of
39

05/14/17 71
72
of
39

05/14/17 72

Das könnte Ihnen auch gefallen