Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Chapter 3 introduced the concept of segmentation, which is the process of dividing an image into areas of related content. These areas consist of pixels that all share a particular characteristic, and one of the more frequently used characteristics is color. It is easy to use color to segment an image. This technique is very effective when a color of the desired object is substantially different from the background color, such as tracking a brightly colored object such as a ball. In this case, use the color difference to segment the image and remove the background from the image, leaving just the object of interest.
This works by essentially subtracting one image from another. To
understand this, first consider how subtraction works with pixels (a topic
which is covered more extensively in the next chapter). Assume that the
pixel at point (0, 0) is purple, with
the RGB triplet (100, 0, 100). Take an
identical pixel—(100, 0, 100)—and
subtract it from the original pixel. To do this, simply subtract each
element from its corresponding value. (100, 0,
100) - (100, 0, 100) = (0, 0, 0). Since (0, 0, 0) is the RGB value for black,
subtracting the same RGB value from a pixel results in a black pixel.
Different colored pixels can also be subtracted from each other. For
example, (100, 0, 100) - (90, 0, 10) = (10, 0,
90), which results in a mostly blue pixel. Subtracting images is
just like subtracting pixels, with the system going through the image on a
pixel-by-pixel basis and performing the subtraction for each pixel.