cs 6825: binary image processing – binary blob metrics

17
CS 6825: Binary Image CS 6825: Binary Image Processing – binary Processing – binary blob metrics blob metrics

Upload: anis-page

Post on 12-Jan-2016

227 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS 6825: Binary Image Processing – binary blob metrics

CS 6825: Binary Image CS 6825: Binary Image Processing – binary blob Processing – binary blob

metricsmetrics

Page 2: CS 6825: Binary Image Processing – binary blob metrics

Recall - Creating a Binary Image - Recall - Creating a Binary Image - ThresholdingThresholding

)),((),(),( yxfTyxgyxf

)( TInput gray-level value Output gray-level value

)( T

0

2

Page 3: CS 6825: Binary Image Processing – binary blob metrics

““Blob Detection” - SegmentationBlob Detection” - Segmentation

Often with binary images such Often with binary images such as the one shown here, you as the one shown here, you want to detect the separate want to detect the separate “blobs”, connected groupings of “blobs”, connected groupings of object pixels.object pixels.

Each blob may represent an Each blob may represent an entirely separate object or a entirely separate object or a surface of an object.surface of an object.

When using color or grey scale When using color or grey scale images this process is called images this process is called segmentation. We will discuss We will discuss this in another module.this in another module.

Here “object pixels” are labeled black.

We have 12 blobs inbinary image, eachcorresponding to adifferent object.

12

3 45

6 7 89

1011

12

Page 4: CS 6825: Binary Image Processing – binary blob metrics

Knowing your blobs: Label ImageKnowing your blobs: Label Image

The output of a The output of a segmentation algorithm on segmentation algorithm on a binary image will be a binary image will be what is called a “label what is called a “label image”. image”.

Basically, it gives a unique Basically, it gives a unique identifier (like number the identifier (like number the blobs 0 to n) for each blob blobs 0 to n) for each blob and every pixel that and every pixel that belongs to that blob gets belongs to that blob gets its label id.its label id.

The color image show the The color image show the label image where each label image where each unique label id has a unique label id has a different colordifferent color

Original Binary Image

Label Image – Colors indicatedifferent blobs, random colorswere assigned

Page 5: CS 6825: Binary Image Processing – binary blob metrics

Blob DetectionBlob Detection

Blob = connected Blob = connected pixels. This image pixels. This image has 4 blobs ( that has 4 blobs ( that are are 8 – connected))

• See our previous See our previous lecture on lecture on neighborhoods to neighborhoods to review 8- connected.review 8- connected.

Page 6: CS 6825: Binary Image Processing – binary blob metrics

Blob Detection Recursive AlgorithmBlob Detection Recursive Algorithm

1.1. Initialize your label image with no labels Initialize your label image with no labels for all pixels.for all pixels.

2.2. Scan your binary image and find the first Scan your binary image and find the first non-zero pixel, that has no label. Create non-zero pixel, that has no label. Create a label for it in the label image.a label for it in the label image.

3.3. Find all unmarked non-zero neighbors Find all unmarked non-zero neighbors and mark them as visited with the same and mark them as visited with the same label id.label id.

4.4. For each of these neighbors, go to step For each of these neighbors, go to step 3.3.

5.5. Repeat step 2 until you have scanned Repeat step 2 until you have scanned the entire image.the entire image.

Page 7: CS 6825: Binary Image Processing – binary blob metrics

Blob Detection Iterative AlgorithmBlob Detection Iterative Algorithm

Scan the array, raster fashion.Scan the array, raster fashion. When a non-zero pixel is found, When a non-zero pixel is found,

look above and to left for other look above and to left for other non-zero pixels and if one is non-zero pixels and if one is found, join the current pixel to found, join the current pixel to this blob. Join blobs at the bottom this blob. Join blobs at the bottom of U's.of U's.

Page 8: CS 6825: Binary Image Processing – binary blob metrics

Example: Labeling Blobs (here application is Example: Labeling Blobs (here application is medical image – cell detection)medical image – cell detection)

AdaptiveSmoothing &Thresholding

ConnectedComponents

Labelingimage

Binary imageRegionslabeled

Image Binary Segmentation Connected Components Labeling

Page 9: CS 6825: Binary Image Processing – binary blob metrics

Small Blob removalSmall Blob removal

Small blobs considered “noise” , not Small blobs considered “noise” , not important.important.

For all pixels f(x,y), left to right, top to bottomFor all pixels f(x,y), left to right, top to bottom { counter(label(x,y)) ++; } { counter(label(x,y)) ++; } //increment count of this label//increment count of this label

//remove blobs with less than S pixels//remove blobs with less than S pixels

For all pixels f(x,y), left to right, top to bottomFor all pixels f(x,y), left to right, top to bottom

{ if f(x,y)=0, do nothing.{ if f(x,y)=0, do nothing.

if f(x,y)=1 and counter(label(x,y))<S)if f(x,y)=1 and counter(label(x,y))<S)

then set f(x,y)=0 then set f(x,y)=0

} }

Page 10: CS 6825: Binary Image Processing – binary blob metrics

Blob MeasurementsBlob Measurements

Often wish to measure geometric Often wish to measure geometric properties on blobsproperties on blobs

Page 11: CS 6825: Binary Image Processing – binary blob metrics

Geometric Properties: Area of a blobGeometric Properties: Area of a blob

SizeSize The area A is measured as The area A is measured as

the number of pixels in the the number of pixels in the region weighted by their region weighted by their intensity.intensity.

Below B represents a set of Below B represents a set of pixels belonging to a pixels belonging to a “blob” that we wish to “blob” that we wish to measure the area of. This measure the area of. This could be, for example the could be, for example the black pixels in the hole of black pixels in the hole of the manufacturing object the manufacturing object we saw previously. we saw previously.

Page 12: CS 6825: Binary Image Processing – binary blob metrics

Geometric Properties: Center position of blobGeometric Properties: Center position of blob

The equation below The equation below calculates the calculates the center of the center of the region region x, yx, y. .

Page 13: CS 6825: Binary Image Processing – binary blob metrics

Geometric Properties: OrientationGeometric Properties: Orientation OrientationOrientation To have a unique orientation along the length of To have a unique orientation along the length of

an object, the object must be elongated in one an object, the object must be elongated in one direction. If this is the case, the axis of elongation direction. If this is the case, the axis of elongation can be used to define the orientation. The axis of can be used to define the orientation. The axis of least second moment is equivalent to the axis of least second moment is equivalent to the axis of least inertia and is used as the axis of elongation. least inertia and is used as the axis of elongation. The axis of second moment for an object is that The axis of second moment for an object is that line for which the sum of the squared distances line for which the sum of the squared distances between the object pixels and the line is between the object pixels and the line is minimum. minimum.

Page 14: CS 6825: Binary Image Processing – binary blob metrics

Geometric Properties: ProjectionsGeometric Properties: Projections The projection of a binary image onto a line can be The projection of a binary image onto a line can be

useful for segmenting areas along the line for further useful for segmenting areas along the line for further processing. Consider the task of trying to find processing. Consider the task of trying to find separation between horizontal lines of text on a page. separation between horizontal lines of text on a page. If you were to perform a projection along a vertical If you were to perform a projection along a vertical line, for black text against a white background the line, for black text against a white background the high values of the projection would indicate the line high values of the projection would indicate the line separations.separations.

Text image and vertical projection.

             600

700

800

900

1000

1100

1200

1300

1400

1500

i

V[i]

These lines/rows of imagecontain the words “To: Lynne”as they have lower values/more black.

Page 15: CS 6825: Binary Image Processing – binary blob metrics

Example: Example: OCR

First Vertical Projection is used to detect lines First Vertical Projection is used to detect lines in text to separate them from each other. in text to separate them from each other. The valleys in the projection curve indicate The valleys in the projection curve indicate areas between lines.areas between lines.

Line 1

Line 2

Line 3

Line 1 Line 2 Line 3

Page 16: CS 6825: Binary Image Processing – binary blob metrics

Example: Example: OCR For each line of text, Horizontal Projection is used to For each line of text, Horizontal Projection is used to

detect and separate characters in it.detect and separate characters in it. Valleys again indicate possible separation between Valleys again indicate possible separation between

characters. This is harder to see visually.characters. This is harder to see visually.

Page 17: CS 6825: Binary Image Processing – binary blob metrics

ConclusionConclusion

We learned about some of the We learned about some of the properties / “features” that are used properties / “features” that are used for Binary Imagesfor Binary Images• Started with finding of “blobs” (idea is a blob is part of an object, or an Started with finding of “blobs” (idea is a blob is part of an object, or an

entire object or could be more tan one object…it is object related).entire object or could be more tan one object…it is object related).• Looked at an algorithm (there are many) to find blobsLooked at an algorithm (there are many) to find blobs• How to remove small blobsHow to remove small blobs• Features of a blob : size, center, orientation, projections.Features of a blob : size, center, orientation, projections.

• THERE are MANY more possible features THERE are MANY more possible features – can you think of any? How – can you think of any? How about shape, or diameter, or length of perimeter, etc.about shape, or diameter, or length of perimeter, etc.