This page is a part of the Computer Vision Wiki. The wiki is devoted to computer vision, especially low level computer vision, digital image analysis, and applications. The exposition is geared towards software developers, especially beginners. The wiki contains discussions of computer vision and related issues, mathematics, algorithms, code snippets, source code, and compiled software. Copyright © Intelligent Perception

# Objects in gray scale images

Objects in a gray scale image should be either connected darker regions surrounded by lighter background, or connected lighter regions surrounded by darker background. We choose the former.

Objects are connected darker regions surrounded by lighter background with lighter holes in them.

Note that objects should not be identified as flat areas, i.e., the areas where pixels have the same gray level. The approach was appropriate for binary images, but in case of gray scale images this would produce boundaries of objects. We are looking for areas where pixels have the same gray level or less. For example, in the image below all rectangles are objects.

This principle still leaves some room for ambiguity. In the image to the left, some rectangles are contained in bigger ones. According to the above principle there are total of 17. However not all of them should be counted. To have the correct count of objects in a gray scale image, we will follow this principle.

If one object contains another, only one of them should be counted.

The principle is vacuously true for binary images. For gray scale images, the larger object is simply the background for the smaller one. An extreme case is when the larger object is the whole image. Clearly, it should not be counted.

If only one of the two is counted, which one? More importantly, which one should be captured, measured, etc?

The answer will be given by the user. He will decide what is and what is not important in the image. For example, objects that are too small or have too low contrast are unimportant. They are noise. Should all objects that aren't noise be counted? No, because some of them may contain other objects. These objects represent are the background for other objects. The noise objects and the background objects are inactive. The rest are active.

Thus we have this rule:

Background objects contain active objects that contain noise objects - only the active ones are counted.

To illustrate consider the graph below. It describes the relation between all objects in the image - each object contains the one the arrow point at. 'I' stand for the object which is the whole image. For the sake of simplicity we ignore light objects.

Depending on the analysis setting, some of these objects will be

• active (circled with red),
• background (circled with brown), or
• noise (no marking).

Consider the two examples below.

• If there are no restrictions from the user (no noise), there are 14 objects - 10 dark and 4 light.
• If the user decides that everything smaller than say 500 pixels is noise, you are left with just 8 dark objects.
The complete graph.
Analysis: 10 dark and 4 light active objects.
Analysis: 10 active (dark) nodes in the graph.
Analysis: 8 dark active objects.
Analysis: 8 active nodes in the graph.

The graph is a tree [1], which may be called the inclusion tree. Using the standard terminology,

• the whole image object is the root node,
• noise is the union of a collection of subtrees corresponding to nodes,
• active nodes are leaf nodes of what's left after noise nodes have been removed,
• backgound nodes are the rest.

For light objects the tree is "upside down". Dark and light trees together form Frame Graphs.

Some users have expressed the concern that the larger gray rectangle should also be counted because it's just another object behind the smaller ones. However, these are 2D images and there is no "behind" in 2D...

As another justification for our approach, consider this situation. The image with 255 concentric circles (rings) with growing - as you move from the center - levels of gray does not have 256 objects, it's one "dark" object. The situation is illustrated below. The first image contains a black circle and the second its blurred version. In either image, there is only a single object. This is the case even though if you zoom in on the second image, it may appear that lighter objects stick out "from under" darker ones.

A black circle.
A black circle blurred.

There may be many characteristics that evaluate the importance of objects in terms of noise vs not noise. Some of the most important ones are discussed in Measuring objects.