chapter 3 binary image analysis. types of images ► digital image = i[r][c] is discrete for i, r,...

Post on 25-Dec-2015

233 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Chapter 3Chapter 3

Binary Image AnalysisBinary Image Analysis

Types of imagesTypes of images

►Digital image = I[r][c] is discrete for I, r, and Digital image = I[r][c] is discrete for I, r, and c.c. B[r][c] = binary image - range of I is in {0,1}B[r][c] = binary image - range of I is in {0,1} B’[r][c] – complement or inverse of BB’[r][c] – complement or inverse of B

= 1 if B[r][c]=0= 1 if B[r][c]=0

= 0 if B[r][c]=1= 0 if B[r][c]=1

Gray-scale image = range of I is in {min, min+1,Gray-scale image = range of I is in {min, min+1,…,max-1,max}…,max-1,max}

Multispectral image = vector-valuedMultispectral image = vector-valued►Ex. Color image = range is in {<r,g,b> | (r,g,b) in {0,1,Ex. Color image = range is in {<r,g,b> | (r,g,b) in {0,1,

…,max} }…,max} }

How do we create binary How do we create binary images?images?

►By selecting (foreground) pixels of By selecting (foreground) pixels of interest and thereby separating them interest and thereby separating them from background pixels = segmentationfrom background pixels = segmentation Ex. Thresholding = selecting ranges of gray Ex. Thresholding = selecting ranges of gray

(or color) values(or color) values►Ex.Ex.

1 if value>1001 if value>100 0 otherwise0 otherwise

0 = background0 = background 1 = foreground1 = foreground

Pixel and its neighborsPixel and its neighbors

►4-neighbors/4-adjacent/4-connected4-neighbors/4-adjacent/4-connected { <r-1,c>, <r+1,c>, <r,c-1>, <r,c+1> }{ <r-1,c>, <r+1,c>, <r,c-1>, <r,c+1> } Or as displacements:Or as displacements:

►{ <-1,0>, <+1,0>, <0,-1>, <0,+1> }{ <-1,0>, <+1,0>, <0,-1>, <0,+1> }

►How about 8-adjacent?How about 8-adjacent? Distances?Distances?

MasksMasks

► Mask = set of pixel positions and Mask = set of pixel positions and corresponding values called weightscorresponding values called weights

► Mask origin = Mask origin = usuallyusually center center► How?How?

1.1. Calculate sum of productsCalculate sum of products► BoundaryBoundary

1.1. Replicate nearest pixel valueReplicate nearest pixel value

2.2. Use 0Use 0

2.2. Normalize (or an amplitude shift will occur)Normalize (or an amplitude shift will occur)

Applying masks to imagesApplying masks to images

Applying masks to imagesApplying masks to images

►Derived from convolution:Derived from convolution:

►Discrete form is cross correlation:Discrete form is cross correlation:

► where f is the input image, h is the mask/filter kernel, and g is the output where f is the input image, h is the mask/filter kernel, and g is the output image resultimage result

ydxdyxfyyxxhyxfyxh ,,,,yx,g

x y

yxfyyxxhyxfyxh ,,,,yx,g

ConvolutionConvolution

►See See http://en.wikipedia.org/wiki/Convolution for some nice animations. for some nice animations.

1*40+2*40+1*80+

2*40+4*40+2*80+

1*40+2*40+1*80

=800

1*40+2*80+1*80+

2*40+4*80+2*80+

1*40+2*80+1*80

=1120

But what about borders?But what about borders?

►When we are missing data at the edges, When we are missing data at the edges, we typically do one of the following:we typically do one of the following:1.1. Copy to the missing value, the nearest Copy to the missing value, the nearest

neighboring value.neighboring value.

2.2. Use 0 for the missing value(s).Use 0 for the missing value(s).

(Regardless, it really doesn’t matter, but (Regardless, it really doesn’t matter, but we need to consistently do something.)we need to consistently do something.)

1*40+2*40+1*40+

2*40+4*40+2*40+

1*40+2*40+1*40

=640

Method 1: copy nearest

The importance of The importance of normalizing the result.normalizing the result.

►Otherwise, the values might get larger Otherwise, the values might get larger and larger (brighter and brighter).and larger (brighter and brighter).

1+2+1+

2+4+2+

1+2+1

=16

640/16

1 2 1

2 4 2

1 2 1

Counting objects (instead of Counting objects (instead of holes)holes)

► If we complement our masks from the If we complement our masks from the hole counting algorithm, we can count hole counting algorithm, we can count objects!objects!

►(Or if we complement our image, we (Or if we complement our image, we can count objects!)can count objects!)

I don’t care for this format!

Object counting assumptions Object counting assumptions (complement of hole counting (complement of hole counting

assumptions)assumptions)

1.1. All image border pixels must be 0s.All image border pixels must be 0s.

2.2. Each region of 1s (objects) must be Each region of 1s (objects) must be 4-connected4-connected..

3.3. Objects must also be Objects must also be simply simply connectedconnected (not contain any holes). (not contain any holes).

Implement object counting Implement object counting algorithmalgorithm

► Check assumptions 1 and 2.Check assumptions 1 and 2. (Skip 3 for now.)(Skip 3 for now.)

► Report number of objects.Report number of objects.

► Exercise 3.1 p. 56 - Efficiency of counting objects.Exercise 3.1 p. 56 - Efficiency of counting objects.

What is the maximum number of times that the function What is the maximum number of times that the function count_objectscount_objects examines each pixel of the image? examines each pixel of the image?

How can functions How can functions external_matchexternal_match and and internal_matchinternal_match be coded to be as efficient as possibly?be coded to be as efficient as possibly?

More object analysisMore object analysis

►So far, we can count objects!So far, we can count objects!

But how big are they?But how big are they?

What shape are they?What shape are they?

PathsPaths

There exists a path from (xThere exists a path from (x11,y,y11) to (x) to (xnn,y,ynn))

iff there exists a sequence (xiff there exists a sequence (x11,y,y11), ), (x(x22,y,y22), … , (x), … , (xnn,y,ynn))

s.t. all (xs.t. all (xii,y,yii) and (x) and (xi+1i+1,y,yi+1i+1) are (4- or 8-) ) are (4- or 8-) connected and B(xconnected and B(xii,y,yii)=B(x)=B(xi+1i+1,y,yi+1i+1).).

Connected componentConnected component

A connected component of value v is a A connected component of value v is a set of pixels C with:set of pixels C with:

1.1. each having value veach having value v

2.2. and for every c and d in C, there exists a and for every c and d in C, there exists a path from c to d.path from c to d.

Objects are 1s (and white) here.

LabelsLabels

►0 = background (not part of any object)0 = background (not part of any object)

►1 = first labeled object1 = first labeled object►2 = second labeled object2 = second labeled object►……

►-1 = part of an unlabeled object (ready -1 = part of an unlabeled object (ready for labeling)for labeling)

I don’t care for this format!

Recursive connected components algorithm:

3 functions

I don’t care for this format!

Recursive connected components algorithm

// 0 --> 0; 1 --> -1// incremented before use so first will actually be 1

I don’t care for this format!

Recursive connected components algorithm

(Why not use r and c instead of L and P, respectively?)

I don’t care for this format!

Recursive connected components algorithm

<-- What does this mean/do?

<-- recursion!

This is an example of a flood fill algorithm (see http://en.wikipedia.org/wiki/Flood_fill for nice animations).

Begin skip other Begin skip other algorithms in this algorithms in this

section.section.

End skip.End skip.

top related