Top Banner
1
67

1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Dec 25, 2015

Download

Documents

Daisy Copeland
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

1

Page 2: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Binary Image B(r,c)

2

0 represents the background 1 represents the foreground

000100100010000001111000100000010010001000

Page 3: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Binary Image Analysis is used in a number of

practical applications, e.g.

3

• Part inspection

• Shape analysis

• Enhancement

• Document processing

Page 4: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

What kinds of operations?

4

Separate objects from background and from one another

Aggregate pixels for each object

Compute features for each object

Page 5: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Example: red blood cell image Many blood cells are

separate objects Many touch – bad! Salt and pepper

noise from thresholding

How useable is this data?

5

Page 6: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Results of analysis 63 separate

objects detected

Single cells have area about 50

Noise spots Gobs of cells

6

Page 7: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Binary Image Operations

7

1. Thresholding a gray-tone image2. Convolution3. Morphology4. Feature extractions (area, centroid) 5. Connected components analysis

Page 8: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

1. Thresholding

8

•Convert gray level or color image into binary image•Use histogram•Definition: The Histogram of a gray-level image I is defined as

H(m) = { (r,c) : I(r,c) =m) }

Where m spans the gray values

Page 9: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Histogram-Directed Thresholding

9

How can we use a histogram to separate animage into 2 (or several) different regions?

Is there a single clear threshold? 2? 3?

Page 10: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Histogram

Background is black Healthy cherry is bright Bruise is medium dark Histogram shows two

cherry regions (black background has been removed)

10

gray-tone values

pixelcounts

0 256

Page 11: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Automatic Thresholding: Otsu’s Method

11

Assumption: the histogram is bimodal

t

Method: find the threshold t that minimizesthe weighted sum of within-group variancesfor the two groups that result from separatingthe gray tones at value t.

Grp 1 Grp 2

Page 12: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Thresholding Example

12

original gray tone image binary thresholded image

Page 13: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

2. Convolution Given a gray level image I(r,c) and a mask m(r,c)

convolution is

I(r,c)*m(r,c)= ΣΣ I(k,l) . m(r-k,m-l)

13

Masks

Page 14: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

SMOOTHING MASKS

Page 15: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Convolution of an İmage with a Mask

15

Page 16: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.
Page 17: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Image Enhancement WITH AVERAGING AND THRESHOLDING

Image Enhancement WITH AVERAGING AND THRESHOLDING

Page 18: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

3. Mathematical Morphology Morphology: Study of forms of animals

and plants Mathematical Morphology: Study of

shapes Similar to convolution Arithmetic operations Set Operations

18

Page 19: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Need to define Image as a Set Given a binary image I (r,c), assume 1

correspond to object 0 correspond to backround.

Define a set with elements to the coordinates of the object

X = { (r1,c1), (r2,c2),….}

19

Page 20: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

111000

111000

000000

000000

X=

20

Page 21: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Set OperationsSet Operations

Page 22: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Set Operations on ImagesSet Operations on ImagesAND, ORAND, OR

Set Operations on ImagesSet Operations on ImagesAND, ORAND, OR

Page 23: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

TRANSLATION REFLECTIONTRANSLATION REFLECTIONTRANSLATION REFLECTIONTRANSLATION REFLECTION

Page 24: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Set OperationsSet Operations

Page 25: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Morphologic Operations

25

Binary mathematical morphology consists of twobasic operations

dilation and erosion

and several composite relations

closing and opening

Page 26: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Dilation:

26

Dilation expands the connected sets of 1s of a binary image.

It can be used for

1. growing regions

2. filling holes and gaps

Page 27: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Structuring Elements

27

A structuring element is a shape mask used inthe basic morphological operations.

They can be any shape and size that isdigitally representable, and each has an origin.

boxhexagon disk

something

box(length,width) disk(diameter)

Page 28: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Dilation with Structuring Element S: ={ Z: (Sz)∩ B≠ Φ}

28

The arguments to dilation and erosion are

1. a binary image B2. a structuring element S

dilate(B,S) takes binary image B, places the originof structuring element S over each 1-pixel, and ORsthe structuring element S into the output image atthe corresponding position.

0 0 0 00 1 1 00 0 0 0

11 1

0 1 1 00 1 1 10 0 0 0

originBS

dilate

B S

B S

Page 29: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

DILATIONDILATION

Page 30: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

DILATIONDILATION

Page 31: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Erosion BΘS ={ Z: (Sz) B}

31

Erosion shrinks the connected sets of 1s of a binary image.

It can be used for

1. shrinking features

2. Removing bridges, branches and small protrusions

Page 32: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Erosion with Structuring Elements

32

erode(B,S) takes a binary image B, places the origin of structuring element S over every pixel position, andORs a binary 1 into that position of the output image only ifevery position of S (with a 1) covers a 1 in B.

0 0 1 1 00 0 1 1 00 0 1 1 01 1 1 1 1

111

0 0 0 0 00 0 1 1 00 0 1 1 00 0 0 0 0

B S

origin

erode

B S

Page 33: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

EROSİON:EROSİON:

Page 34: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

IMAGE ENHANCEMENT WİTH MORPHOLOGYIMAGE ENHANCEMENT WİTH MORPHOLOGY

Page 35: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Example to Try

35

0 0 1 0 0 1 0 0 0 0 1 1 1 1 1 0 1 1 1 1 1 1 0 01 1 1 1 1 1 1 10 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0

1 1 11 1 11 1 1

erode

dilate with same structuring element

SB

Page 36: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Opening and Closing

36

• Closing is the compound operation of dilation followed by erosion (with the same structuring element)

• Opening is the compound operation of erosion followed by dilation (with the same structuring element)

Page 37: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Use of Opening

37

Original Opening Corners

1. What kind of structuring element was used in the opening?

2. How did we get the corners?

Page 38: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

OPENİNG AND CLOSİNGOPENİNG AND CLOSİNGOPENİNG AND CLOSİNGOPENİNG AND CLOSİNG

Page 39: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

FINGERPRİNT RECOGNİTİONFINGERPRİNT RECOGNİTİON

Page 40: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

HOW DO YOU REMOVE THE HOLESHole: A closed backround region surrounded by object pixels

HOW DO YOU REMOVE THE HOLESHole: A closed backround region surrounded by object pixels

Page 41: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

41

Erode with hole ring and dilate with hole mask

Page 42: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Morphological Analysis for Bone detectionMorphological Analysis for Bone detection

Page 43: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

OBJECT DETECTIONOBJECT DETECTION

Page 44: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

BOUNDARY EXTRACTİONBoundary: A set of one-pixel-wide

connected pixels which has at least one neighbor outside the object

BOUNDARY EXTRACTİONBoundary: A set of one-pixel-wide

connected pixels which has at least one neighbor outside the object

Page 45: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

BOUNDARY EXTRACTİONBOUNDARY EXTRACTİON

Page 46: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Skeleton FindingSkeleton: Set of one-pixel wide connected pixels which

are at equal distance from at least two boundary pixels

Skeleton FindingSkeleton: Set of one-pixel wide connected pixels which

are at equal distance from at least two boundary pixels

Page 47: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Morphological Image ProcessingMorphological Image Processing

Page 48: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.
Page 49: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Morphological OperationsMorphological Operations

Page 50: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Morphological OperationsMorphological Operations

Page 51: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Skeleton finding:Skeleton: Set of one-pixel wide connected pixels which

are at equal distance from at least two boundary pixels

Skeleton finding:Skeleton: Set of one-pixel wide connected pixels which

are at equal distance from at least two boundary pixels

Page 52: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Gear Tooth Inspection

52

originalbinary image

detecteddefects

How didthey do it?

Page 53: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Some Details

53

Page 54: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Region Properties-Features

54

Properties of the regions can be used to recognize objects.

• geometric properties (Ch 3)

• gray-tone properties

• color properties

• texture properties

• shape properties (a few in Ch 3)

• motion properties

• relationship properties (1 in Ch 3)

Page 55: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Geometric and Shape Properties

55

• area:

• centroid:

• perimeter :

• perimeter length:

• circularity:

Page 56: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

• elongation• mean and standard deviation of radial

distance• bounding box• extremal axis length from bounding

box• second order moments (row, column,

mixed)• lengths and orientations of axes of

best-fit ellipse

56

Page 57: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

4. Connected Components Labeling

57

Once you have a binary image, you can identify and then analyze each connected set of pixels.

The connected components operation takes in a binary image and produces a labeled image in which each pixel has the integer label of either the background (0) or a component.

binary image after morphology connected components

Page 58: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Methods for CC Analysis

58

1. Recursive Tracking (almost never used)

2. Parallel Growing (needs parallel hardware)

3. Row-by-Row (most common)

• Classical Algorithm (see text)

• Efficient Run-Length Algorithm (developed for speed in real industrial applications)

Page 59: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Equivalent Labels

59

0 0 0 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 10 0 0 1 1 1 1 0 0 0 1 1 1 1 0 0 0 1 10 0 0 1 1 1 1 1 0 0 1 1 1 1 0 0 1 1 10 0 0 1 1 1 1 1 1 0 1 1 1 1 0 0 1 1 10 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 10 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 10 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 10 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 10 0 0 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1

Original Binary Image

Page 60: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Equivalent Labels

60

0 0 0 1 1 1 0 0 0 0 2 2 2 2 0 0 0 0 30 0 0 1 1 1 1 0 0 0 2 2 2 2 0 0 0 3 30 0 0 1 1 1 1 1 0 0 2 2 2 2 0 0 3 3 30 0 0 1 1 1 1 1 1 0 2 2 2 2 0 0 3 3 30 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 3 3 30 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 3 3 30 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 10 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 10 0 0 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1

The Labeling Process

1 21 3

Page 61: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Run-Length Data Structure

61

1 1 1 11 1 11 1 1 1

1 1 1 1

0 1 2 3 401234

U N U S E D 00 0 1 00 3 4 01 0 1 01 4 4 02 0 2 02 4 4 04 1 4 0

row scol ecol label

01234567

Rstart Rend

1 23 45 60 07 7

01234 Runs

Row Index

BinaryImage

Page 62: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Run-Length Algorithm

62

Procedure run_length_classical { initialize Run-Length and Union-Find data structures count <- 0

/* Pass 1 (by rows) */

for each current row and its previous row { move pointer P along the runs of current row move pointer Q along the runs of previous row

Page 63: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Case 1: No Overlap

63

|/////| |/////| |////|

|///| |///| |/////|

Q

P

Q

P

/* new label */ count <- count + 1 label(P) <- count P <- P + 1

/* check Q’s next run */Q <- Q + 1

Page 64: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Case 2: Overlap

64

Subcase 1: P’s run has no label yet

|///////| |/////| |/////////////|

Subcase 2:P’s run has a label that isdifferent from Q’s run

|///////| |/////| |/////////////|

QQ

P P

label(P) <- label(Q)move pointer(s)

union(label(P),label(Q))move pointer(s)

}

Page 65: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Pass 2 (by runs)

65

/* Relabel each run with the name of the equivalence class of its label */For each run M { label(M) <- find(label(M)) }

}

where union and find refer to the operations of theUnion-Find data structure, which keeps track of setsof equivalent labels.

Page 66: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Labeling shown as Pseudo-Color

66

connectedcomponentsof 1’s fromthresholdedimage

connectedcomponentsof clusterlabels

Page 67: 1. Binary Image B(r,c) 2 0 represents the background 1 represents the foreground 00010010001000 00011110001000 00010010001000.

Region Adjacency Graph

67

A region adjacency graph (RAG) is a graph in whicheach node represents a region of the image and an edgeconnects two nodes if the regions are adjacent.

1

2

34

1 2

34