Arithmetic operations

Arithmetic operations#

In the end, an image is an array of numbers. So mathematical operations can be performed on these numbers. In this section, we consider 2D images but the generalization to different dimensions is obvious.

Addition#

The addition of two images \(f\) and \(g\) of the same size results in a new image \(h\) of the same size whose pixels are the sum of the pixels in the original images:

\[ \forall m, n,\quad h(m,n) = f(m,n) + g(m,n). \]

Fig. 20 gives an example of image addition to produce an artistic effect. Addition can also be used to denoise a series of images.

../_images/addition.svg

Fig. 20 The image on the right is the sum of the two images on the left.#

Subtraction#

The subtraction of two images is used for example to detect changes (Fig. 21).

\[\begin{split} &\forall m, n,\quad h(m,n) = f(m,n) - g(m,n) \\ \text{or}\qquad &\forall m, n,\quad h(m,n) = | f(m,n) - g(m,n) | \end{split}\]
../_images/subtraction.svg

Fig. 21 The image on the right is the difference between the two images on the left. Note that the image of difference has values between \(-255\) and \(255\).#

Division#

The division of two images is used to correct non-homogeneous illumination. Fig. 22 illustrates the removal of shadow.

\[ \forall m, n,\quad h(m,n) = \frac{f(m,n)}{g(m,n)}. \]
../_images/division.svg

Fig. 22 The right image is the division of the left image by the right image.#