Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

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 ff and gg of the same size results in a new image hh of the same size whose pixels are the sum of the pixels in the original images:

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

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

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

Figure 1: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 (Figure 2).

∀m,n,h(m,n)=f(m,n)−g(m,n)or∀m,n,h(m,n)=∣f(m,n)−g(m,n)∣\begin{align*} &\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{align*}
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.

Figure 2: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. Figure 3 illustrates the removal of shadow.

∀m,n,h(m,n)=f(m,n)g(m,n).\forall m, n,\quad h(m,n) = \frac{f(m,n)}{g(m,n)}.
The right image is the division of the left image by the right image.

Figure 3:The right image is the division of the left image by the right image.