binary image algorithm. what is an object? what is an object? – binary image connected cluster of...

26
Binary Image Algorithm

Upload: alexander-gill

Post on 26-Mar-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Binary Image Algorithm

Page 2: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

What is an Object?• What is an object?

– Binary image• Connected cluster of black pixels on a white background• Connected cluster of white pixels on a black background

• Objects can also have holes in them

2

Page 3: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Goals of Image Analysis

• Identify objects– Objects can have holes in them

• Find their locations• Find their size

• If certain objects are small, it can be ignored.• The decision to ignore any size object is taken

by the user

Page 4: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Loss less Processing

• Nothing is removed or ignored • No iteration, approximation • No floating point arithmetic

4

Page 5: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Cell Decomposition• Object is represented by

– List of pair of numbers• Pixel is square

– Instead of a point

5

Page 6: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Definitions• Definitions

– A vertex is a 0-cell– An edge is a 1-cell

• Boundaries consists of 2 end-points as 0-cells

– A pixel is a 2-cell• Boundaries consists of 4 edges as 1-cell

– A voxel is a 3-cell• Boundaries consists of 6 faces as 2-cells

6

Page 7: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Cell Decomposition of an Image

Two adjacent edges as 1-cells share a vertex, a 0-cell

Two adjacent pixels as 2-cells share an edge, 1-cell

Edge: 1-cell

Edge: 1-cell

Vertex: 0-cell

Edge: 1-cell

The image is made of k-cells that are attached to each other along (k-1) cells.

Page 8: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Binary ImagesASSUMPTION:Binary images are analyzed as if they have

black objects on white background

BackgroundObjects

Page 9: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Cycles• 0-cycles represent objects or connected components of the image

– Traversed clockwise• 1-cycles represents holes

– Traversed counterclockwise

Image

Its topological features are represented as cycles. Here A and B are 0-cycles, C and C’ are 1-cycles.

Page 10: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Partition

• A partition is a collection of non-overlapping regions– Connected set of black pixels– Connected set of white pixels

• The partition is achieved by finding boundaries of these regions as 0-cycles and 1-cycles.

Page 11: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Algorithm to Detect Cycles

• Incremental• One pixel at a time are added to the image• The process of adding a pixel starts with

adding its vertices and then its edges

Page 12: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

The Procedure to Add a Pixel

Stage 1-4

Stage 5

Stage 7 Stage 8

Stage 6

Stage 9

Add 4 vertex Add 4 Edges Add Pixel

Page 13: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Example 1

This object has

one 0-cycle “A”

one 1-cycle “B”

Incremental addition of pixels will able to recognize the 2 cycles

Page 14: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Example 1: Add Pixel 1 and 2Add Pixel 1

Add 4 vertexAdd 4 edgesAdd 1 cycle

9 Steps

1

Add Pixel 2

Add 2 vertexAdd 3 edgesAdd 1 cycle

6 Steps

1 2

Page 15: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Example 1: Add Pixel 3 and 4

Add Pixel 3

Add 2 vertexAdd 3 edgesAdd 1 cycle

6 Steps

1 2 3

Add Pixel 4

Add 2 vertexAdd 3 edgesAdd 1 cycle

6 Steps

1 2 3

4

Page 16: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Example 1: Add Pixel 5 and 6

Add Pixel 5

Add 2 vertexAdd 3 edgesAdd 1 cycle

6 Steps

1 2 3

4 5

Add Pixel 6

Add 2 vertexAdd 3 edgesAdd 1 cycle

6 Steps

1 2 3

4 5

6

Page 17: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Example 1: Add Pixel 7 and 8

Add Pixel 7

Add 1 vertexAdd 3 edgesAdd 1 cycle

5 Steps

Add Pixel 8

Add 1 vertexAdd 2 edgesAdd 1 cycle

4 Steps

1 2 3

4 5

6 7

B

1 2 3

4 5

6 7

B

8

Cycle A is complete

Cycle B is complete

Page 18: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Example 2

Page 19: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Example 2: Answer

Page 20: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Pseudo CodeImage Analysis with binary image I

FOR all pixels in I IF pixel P in I is black

THEN CALL AddCell with pixel P END IF

END FOR

Page 21: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Pseudo Code AddCell with pixel P

CALL AddVertex with the upper right of pixel P CALL AddVertex with the upper left of pixel P CALL AddVertex with the lower right of pixel P CALL AddVertex with the lower left of pixel P

CALL AddEdge with the lower edge of pixel P CALL AddEdge with the right edge of pixel P CALL AddEdge with the upper edge of pixel P CALL AddEdge with the left edge of pixel P

CALL RemoveCycle with the 1-cycle that starts at any of these 8 edges that goes counterclockwise

Page 22: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Pseudo Code AddVertex with vertex V

IF the edge = vertex V is active THEN RETURN

ENDIF

Call AddCycle with edge = vertex V

Page 23: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Pseudo Code AddEdge with edge E

IF edge E is active THEN RETURN

END IF

CALL StepForward with edge E RETURNING temporary edge E1 Find the cycle determined by temporary edge E1, A CALL StepForward with the opposite of the edge RETURNING temporary edge E2 Find the cycle determined by temporary edge E2, B

IF A == B THEN CALL SplitCycle with edges E1, E2, and cycle A

ELSE CALL MergeCycles with edge E1 and cycles A, B

END IF

Page 24: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Pseudo Code MergeCycles with cycles A, B and edge E

CALL CreateCycle with edge E RETURNING a new 0-cycle C Add links from A and B to C in the graph 0-Betti --

Page 25: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

Pseudo Code SplitCycle with edge E and cycle A

IF A is a 1-cycle THEN CALL CreateCycle with edge E1 RETURNING a new 0-cycle C CALL CreateCycle with edge E2 RETURNING a new 0-cycle D

END IF

IF A is a 0-cycle THEN CALL CreateCycle with edge E1 RETURNING a new 0-cycle C CALL CreateCycle with edge E2 RETURNING a new 1-cycle D

END IF

1-Betti number ++

Add links from A to C and D in the graph

Page 26: Binary Image Algorithm. What is an Object? What is an object? – Binary image Connected cluster of black pixels on a white background Connected cluster

The output of the algorithm

Traversing a cycle.