Topology Approach to Cell Counting
Mar 26, 2015
Topology Approach to Cell Counting
Goals
• Algorithm detects and captures objects in an image
• This algorithm computes object’s– Locations– Measurement– Identify set of pixels for extraction from the image
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
What is an Object?• What is an object?
– Gray Scale image• Connected cluster of dark pixels on a light background• Connected cluster of light pixels on a dark background
What is an Object?• What is an object?
– Color image• Connected cluster of dark color pixels on a light color background• Connected cluster of light color pixels on a dark color background
Gray Scale Images
• Gray Scale images– For a threshold
• A binary image is created– For each level of gray chosen as threshold
• Collection (255) of binary images are created– As threshold grows
• Objects grows and merge
• Dark pixels form dark objects for each threshold• Light pixels form light objects for each threshold• Light objects may turn out holes in dark objects or vice versa.
Gray Scale Image1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
1 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
2 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7
3 7 6 5 5 5 5 5 5 5 5 5 5 5 5 6 7
4 7 6 5 4 4 4 4 4 4 4 4 4 4 5 6 7
5 7 6 5 4 3 3 3 3 3 3 3 3 4 5 6 7
6 7 6 5 4 3 2 2 2 2 2 2 3 4 5 6 7
7 7 6 5 4 3 2 1 1 1 1 2 3 4 5 6 7
8 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7
9 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7
10 7 6 5 4 3 2 1 1 1 1 2 3 4 5 6 7
11 7 6 5 4 3 2 2 2 2 2 2 3 4 5 6 7
12 7 6 5 4 3 3 3 3 3 3 3 3 4 5 6 7
13 7 6 5 4 4 4 4 4 4 4 4 4 4 5 6 7
14 7 6 5 5 5 5 5 5 5 5 5 5 5 5 6 7
15 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7
16 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
Image size (WxH) = 16x16 pixels
8 Levels of grayBlack = 0White = 7
Gray Scale ImageVisual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
12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
13 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
14 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
15 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Image size (WxH) = 16x16 pixels
Threshold = 0
Level Set:If P(i,j) <= 0 B(i,j) = 0 (Black)Else B(i,j) = 1 (White)
Binary Image1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
7 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1
8 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1
9 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1
10 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1
11 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
13 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
14 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
15 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Image size (WxH) = 16x16 pixels
Threshold = 1
Level Set:If P(i,j) <= 1 B(i,j) = 0 (Black)Else B(i,j) = 1 (White)
Binary Image1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
3 1 1 1 1 1 1 1 1 1 1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 1 1 1 1 1 1 1 1
15 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Image size (WxH) = 16x16 pixels
Threshold = 3
Level Set:If P(i,j) <= 3 B(i,j) = 0 (Black)Else B(i,j) = 1 (White)
Binary Image1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
4 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1
5 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1
6 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1
7 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1
8 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1
9 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1
10 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1
11 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1
12 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1
13 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1
14 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
15 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
16 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Image size (WxH) = 16x16 pixels
Threshold = 4
Level Set:If P(i,j) <= 4 B(i,j) = 0 (Black)Else B(i,j) = 1 (White)
Binary Image1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
3 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1
4 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1
5 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1
6 1 1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image size (WxH) = 16x16 pixels
Threshold = 6
Level Set:If P(i,j) <= 6 B(i,j) = 0 (Black)Else B(i,j) = 1 (White)
Binary Image1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Image size (WxH) = 16x16 pixels
Threshold = 7
Level Set:If P(i,j) <= 7 B(i,j) = 0 (Black)Else B(i,j) = 1 (White)
Characteristics of Objects
• Size = area in pixels• Contrast• Compactness
– Perimeter/(4*Pi*Area)
• Saliency
Loss less Processing
• Nothing is removed or ignored • No iteration, approximation • No floating point arithmetic
Application
• The algorithm will work on the following types of images– That contains certain objects– Blood cells, finger prints, logos, mug shots– Machine vision for industrial inspection
• It will not work on the following images– Images that are light on one side and dark on the
other side
Homology Classes: Betti Numbers
• B1: Number of objects in an image• B2: Number of holes in an object• B3: Number of voids or cavities
B0 (parts) B1 (holes) B2 (voids)
Letter O 1 1 0
Two letters O 2 2 0
Letter B 1 2 0
Donut 1 1 0
Tire 1 2 1
Ball 1 0 1
The tire (torus) has two tunnels represented by these two "cycles". For the donut the blue one does not count because it can be contracted to a point. They are homologous!
On the ball any "cycle" is like that.
Binary Images: Objective
• Identify Objects– Black objects on a white background– White objects on a black background
• Location• Measurement• Identify a set of pixels for extraction from the image
• Later migrate– From: binary to gray to color images– From: 2D to 3D images
Cell Decomposition• Object is represented by
– List of pair of numbers• Pixel is square
– Instead of a point• 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