Chapter 6. Image Arithmetic
As discussed in Chapters 3 and 4, we can think of images as a grid of pixels with each pixel having a color defined as an RGB triplet. Each component in that RGB triplet has a value in the range of 0 to 255. Given this structure and format, it is actually quite easy to perform arithmetic on images, such as addition, subtraction, multiplication, and division. This concept should not be entirely new. Chapter 5 already introduced this idea when using color to segment images. The goal of this section is to examine this concept in further detail, and understand how mathematical manipulation of images is used in a vision system. Topics include:
The basic mathematical operations from elementary school, as applied to images
Using histograms to calibrate the camera
Finding the dominant colors of an image and using that information to segment the image
Basic Arithmetic
Just as with elementary school arithmetic, the easiest place to start is with addition.
Two images can be added together. Underneath the hood, the SimpleCV framework goes through the
two images pixel by pixel, and adds the RGB values of the pixels at corresponding locations
together. Starting at pixel (0,0)
on both images (the top left corner of each image), it will
add the values for each component of the RGB triplet together to get a new RGB triplet. For
instance, if the RGB value of the pixel at (0,0)
in the first image is (1,2,3)
, and the RGB
value at the same (0,0)
point in the second image is
Get Practical Computer Vision with SimpleCV now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.