3. Basic Methods II: Image operations

3.13. Image Arithmetic

Simple mathematical operators like addition or subtraction, and involving two images of equal dimensions, are the foundation of a multitude of further image processing like calibration, comparison, or combination. At this point we are looking at only two images that are involved in the usage of one operation. Image math includes addition, subtraction, multiplication, and division of each one of the pixels of one image with the corresponding pixel of the other image. In the following examples the result of every operation will be a new image itself.

The addition of two images stacks the value of every pixel in image A with the corresponding pixel of image B. Consequently, the image gets brighter. Depending on the maximal allowed pixel value that is used, this operation might result in saturated pixels of the new image, i.e. white pixels that have reached the maximum value. This will lead to information loss and should be avoided if possible. The whole resulting image can for example be re-normalized, so that the brightest pixel equals the maximum allowed value and all other pixels are scaled accordingly. The example below is not adjusted for this case.

Subtracting two images works analogously. In a similar way, the resulting values may lie outside the allowed range of pixel values. This will be the case when one image is subtracted from another with lower pixel values. Here, it is advantageous to add a certain constant value to the equation (the whole image). The example below shows what happens when two images that are in parts almost identical get subtracted from one another. We add the constant value of 150 to every pixel of image A and then perform the subtraction by image B. Subtle differences in the background can be seen as soft lines and shapes in the resulting image. This is expected for nearly identical images with e.g. slightly different exposure times. The darker areas of the cup in the middle even become a bit darker (value 0) since they (very dark tones plus 150) are then indeed over-subtracted. The gray lines across the cup are the result of the subtraction of a light tone (dark cup in image A + 150) with a dark tone (dark lines in image B). The cup on the right side in the resulting image also features gray lines, which are brighter compared to the cup in the middle since the cup is brighter itself. 

A special case of the subtraction of two image is the absolute difference. Here, no adding of a constant is necessary to fully preserve the conveyed information. The absolute value of the difference highlights missing objects, especially those whose brightness value is rather different compared to the area at its position in the other image. Consequently, the black cup in the middle notably stands out. A large part of the cup to the right is not highlighted very strongly, since the brightness of the pixels in its center areas is roughly that of the background in image A. The shadow of the cups in the middle and to the right are also highlighted because of the large difference in brightness to the background. Because our perception of brightness partially depends on the brightness of the surrounding areas, the difference in images is not always intuitive. Subtraction and absolute difference as image operations serve as effective tools in finding even subtle changes. 


Fig. 3.14: Image A (left) and image B (right)