Image Arithmetic
Image arithmetic refers to performing arithmetic operations on the pixel values of one or more images. These operations are useful for combining images, comparing images, and modifying or analysing image information.
Let and represent two input images, where and denote the pixel coordinates. An arithmetic operation between the two images can be represented as
where represents an arithmetic operation and is the resulting image.
For image arithmetic, the input images should generally have the same dimensions, , so that corresponding pixels can be operated on directly.
Pixel-wise Arithmetic Operations
Arithmetic operations are performed independently on corresponding pixels of the input images. Let
be the pixel values at the same location in the two input images. Let be the corresponding pixel value in the output image.
The basic arithmetic operations are addition, subtraction, difference, multiplication, and division.

Figure 1: Pixel-wise arithmetic operations on two input images.
Addition:
Addition combines the intensity values of corresponding pixels of the two images. It can be used, for example, to combine image information or to model the addition of noise to an image.
Subtraction:
Subtraction determines the difference between corresponding pixel values. Since the order of the images matters, and can produce different results.
Difference:
The difference operation uses the absolute value, so the output is always non-negative. It provides a measure of how different the corresponding pixels are in the two images.
Multiplication:
Multiplication combines corresponding pixel values by multiplying them. The resulting values can become much larger than the values in either input image.
Division:
Division computes the ratio between corresponding pixel values. The divisor must be non-zero because division by zero is undefined.
Dynamic Range of an Image
A digital image stores pixel values within a limited range. For a -bit image, the valid range is
For an 8-bit grayscale image, the valid pixel-value range is
However, the result of an arithmetic operation may fall outside this range. This creates an underflow when the result is less than the minimum allowed value and an overflow when the result is greater than the maximum allowed value.
For two 8-bit input images, the theoretical output ranges of the basic operations are:
- Addition:
- Subtraction:
- Difference:
- Multiplication:
- Division:
The result depends on the value of the divisor and can become very large when the divisor is close to zero. Division by zero is undefined.
These ranges show why the result of an arithmetic operation cannot always be stored directly as an 8-bit image.
Handling Values Outside the Valid Range
When an arithmetic operation produces values outside the valid pixel range, the output must be processed before it can be represented as an 8-bit image. Two commonly used approaches are clipping and auto-scaling.
Clipping:
In clipping, values below the minimum allowed value are set to the minimum, and values above the maximum allowed value are set to the maximum.
For an 8-bit image,
where is the clipped output value.
Clipping preserves values that are already within the valid range but discards information beyond the lower and upper limits.
Auto-scaling:
Auto-scaling maps the range of the computed result to the valid range of the output image. For an 8-bit image, the result can be mapped to the range .
Let and be the minimum and maximum values in the result of an arithmetic operation. The auto-scaled value is given by
This transformation maps to and to .
Auto-scaling is useful when the computed values have a wider or different range from the range required for display. However, it changes the numerical representation of the result by mapping the values to a new range.
Understanding the Output
The output of an image arithmetic operation depends on both the selected operation and the pixel values in the input images. For example, addition can produce values greater than 255, subtraction can produce negative values, and multiplication can produce values much larger than either input value.
Therefore, understanding the valid pixel range is important when interpreting the resulting image. Clipping and auto-scaling provide different ways of converting the arithmetic result into a range suitable for an 8-bit image.
In this experiment, the effect of different arithmetic operations on image pixel values and on the dynamic range of the resulting image can be observed directly. This helps in understanding how simple arithmetic operations on pixel values can change the appearance and numerical representation of an image.