Sei sulla pagina 1di 5

An Introduction to

An Introduction to

Computer Vision

Computer Vision

Binary Images

Luke Fletcher

Computer Vision (ENGN4528|ENGN6528)

Luke Fletcher

Contain a fraction of the data of an intensity


image.
In lecture 1 we saw the use of binary images for
constructing masks.
Binary images are particularly useful for

Binary Image Analysis

Identifying objects with distinctive silhouettes, eg


components on a conveyor in a manufacturing plant.
Recognising text and symbols, eg document processing,
or interpreting road signs.
Determining the orientation of objects

Easy to analyse
2

An Introduction to

Moments of Objects

A lot of useful information about a binary


object can be gained from the moments of
the object.
Define the binary image I of an object to be

Luke Fletcher

Centre of mass is given by the 1s t moments

x=

xI( x, y )

I(x , y )

Axis of
orientation

I( x, y)

(U

xx

U xy =

Area is given by the 0th moment

A = I ( x, y)

U yy =

x y

n m
i i

Moments are then given by


A= S

= x n ymI ( x, y )
x

(x x )(y y )I( x, y)

S x = xi

S y y = y i2

(y y ) I( x, y)

S y = yi

S x y = x i yi

U yy = S yy

S 2x
S
S y2

Sx Sy

U xy = S xy
S

Sx
S
Sy

U xx = S xx

Moments can be quickly


calculated from the following
summations
i

y=

S x x = xi2

x =

S = 1

Luke Fletcher

summations can be more


compactly represented as

2
U yy ) + (2.U xy )2

Computer Vision

Let (x i, y i) be all the points on


the object in I, then the

(x x )2 I(x , y)
x

where the 2nd central moments are


U xx =

y I( x , y )

= atan2 2U
. , U xx U yy +
xy

Background

The orientation of an object is defined as


the axis of minimum inertia. This is the
axis of the least 2nd moment, the
orientation of which is

Centroid

Object

y=

1 for pointson theobject


I ( x, y) =
everywhere else
0

An Introduction to

Calculating Moments

Computer Vision

It is a simple matter to prove that these are


equivalent to the definitions on the previous
slide.

An Introduction to

Central Moments

An Introduction to

Normalised moments

Computer Vision
Luke Fletcher

Spatial moments taken from image origin:


M mn =

( x)
x

Luke Fletcher

Centralised moments invariant to translation


Normalised moments invariant to translation and scale:

( y) n I( x, y )

Computer Vision

Centralised moments invariant to translation:

N mn =

(x x )
x

( y y) n I( x, y )

( I ( x, y) )
x

m+ n+2
2

U mn = (x x) m ( y y) nI ( x, y )
x

An Introduction to

Hu invariant moments

An Introduction to

Computer Vision

Computer Vision

Connectedness

Luke Fletcher

Centralised moments invariant to translation


Normalised moments invariant to translation and scale
Hu invariant moments invariant to translation, scale and rotation:
Created by Hu by applying algebraic invariants to normalised moments

Connectedness determines whether 2


binary pixels are connected or not. 4
and 8-connectedness are commonly
used. The xs mark pixels that are
considered connected to p.
Problem with 4 or 8 connectedness:

H 1u= n2 0+n0 2
H 2u= (n2 0+ n0 2) 2 +4n21 1
H 3u= (n3 0+ 3n1 )2 2 + (3n2 1 n0 3)2

H 4u= (n3 0+ n1 2)2 +(n2 1 n0 3)2


2
2
H 5u= (n3 0 3n1 )(
( n3 0+ n1 )2 2 3(n2 1+n0 3)2 ]
2 n
3 0 +n1 )[(
2 n3 0+n1 )
2 3(n2 1+ n
0 3) ]+ (3n2 1n0 )(
3 n2 1+n0 )[
3 3

H 6u= (n2 0 n0 2)[(n3 0+ n1 2) 2 ( n2 1+ n0 3) 2 +4n1 1(n3 0+ n1 2)(n2 1+ n0 3)]


H 7u= (3n2 1+n0 3)(n3 0+n1 2)[(
n3 0+ n1 2)2 3(n2 1+ n0 )3 2] +(n3 0 3n1 2)(n2 1+n0 3)[3( n3 0 +n1 )2 2 ( n2 1+ n0 )3 2]

Luke Fletcher

Dont satisfy the Jordan Curve


Theorem:
A simple curve separates the plane into
two simply connected components.
Using 4- or 8-connectedness a closed
curve does not necessarily divide the
image into two separate connected
components, e.g.

x
x p x
x

x x x
x p x
x x x

4-connected

8-connected

Solutions:

0 1 0
1 0 1
0 1 0

In Matlab bwfill uses 8connectedness for the forground and 4connectedness for the background, or
vice versa .
6-connectedness: e.g. right-skewed 6connected neighbourhood

x x
x p x
x x 0

x x
x p x
x x

Labelling Connected
Components

An Introduction to

An Introduction to

Computer Vision

Computer Vision

Luke Fletcher

Luke Fletcher

Matlab
functions:
bwlabel

Uniquely label each cluster of positive


connected components.
Zero-elements are considered part of the
background and remain zero.
Labelling 4-connected components via a
raster scan (row by row starting top left)
If p = 0 ignore
Else if a and b not labeled, increment label
and label p,
Else if only one of a or b labeled then copy
label to p
Else if a and b labeled
If a and b labeled the same then copy label
to p
Else copy either label to p and recored the
equivalence of the labels

1
1
1
0

1
0
0
0

0
0
1
0

1
0
0
0

1
1
1
0

1
0
0
0

0
0
3
0

2
0
0
0

Binary Image Morphology

a,b,c and d refer to the 4-connected pixel


locations around p:

a
b p c
d

Uses of Morphological
Operators

10

An Introduction to

An Introduction to

Computer Vision

Point Sets and Notation

Luke Fletcher

Computer Vision
Luke Fletcher

Binary objects are considered as point sets.


Morphological operators can:

For point sets A and B denote the:

thin,
thicken,
find boundaries,
find skeletons (medial axes),
convex hulls, and more.

translation of A by x as Ax={a i+x| a iA}


reflection of B as Br = {-bi| biB}
complement of A as Ac ={a i| a iA}
difference of A and B as

Give quantifying information

A-B={ci | (ciA) XOR (ciB)}


11

12

An Introduction to

An Introduction to

Dilation

Computer Vision

Dilation and Erosion

Luke Fletcher

The two basic morphological operations are:

Computer Vision
Luke Fletcher

Dilation of A by structuring element B:


dil(A, B) = {x i | (Bxr A) }
B

Dilation
Erosion

Br
A

Both involve two point sets:


Object of interest
Structuring element

Example: dilating A with the 3 3 structuring


element B centred at the origin.
13

14

An Introduction to

Erosion

An Introduction to

Computer Vision

Combining
Dilation and Erosion

Luke Fletcher

Erosion of A by structuring element B is given by


er(A, B) = {x i | Bx A}

Luke Fletcher

Combine dilation and erosion for:-

B
A

Computer Vision

Opening,
Particularly important
Closing,
Thickening,
Thinning,
Skeletonisation,

Br

Example: eroding A with the 3 3 structuring


element B centred at the origin.
15

16

An Introduction to

Intuitive Interpretations

An Introduction to

Computer Vision

Computer Vision

Closing

Luke Fletcher

Luke Fletcher

Like smoothing from the outside.

Dilation expands an object


Erosion contracts an object
Opening

close(A, B) = er(dil(A,B), B)
A

smoothes contours,
enlarges narrow gaps,
eliminates thin protrusions.

dilation

erosion
close(A,B)

Closing
fills narrow gaps, holes, and small breaks.
17

18

An Introduction to

An Introduction to

Computer Vision

Opening

Computer Vision

Idempotency

Luke Fletcher

Luke Fletcher

Like smoothing from the inside.

Applying opening or closing more than


once has no further effect, i.e.

open(A,B) = dil(er(A,B),B)
= {Bx|BxA}
B

open(open(A,B),B) = open(A,B)

close(close(A,B),B) = close(A,B)
erosion

dilation
open(A,B)

19

20

An Introduction to

Additional Structuring
Operations

An Introduction to

Find Boundary

Computer Vision
Luke Fletcher

Computer Vision
Luke Fletcher

boundary(A,B) = A - er(A, B)

Find boundary of an object


Region filling
Skeletonisation

A
erosion

difference
boundary(A,B)

21

22

An Introduction to

Region Filling

An Introduction to

Computer Vision

Let C0 = p
Calculate

Problem: Fill 8-connected boundary A with


1s given a point inside the boundary p.

Ck = dil(Ck-1,B) A c ,

Use structuring element B, and


Iterative dilations
Intersection
Compliment

Computer Vision

Solution

Luke Fletcher

A
B
23

Luke Fletcher

A
for k = 1,2,

Stop when Ck = Ck-1,


Ck is the interior of A

24

An Introduction to

Skeletonisation

Computer Vision
Luke Fletcher

Skeleton medial axis

Skeletonisation much faster than medial axis


transform!
K 1

skel (A) = {er(A, kB ) open(er( A, kB), B )}


k =0

where
B is structuring element,
er(A,kB) = k successive erosions of A,
K = number of iterations to completely erode A.
25

Potrebbero piacerti anche