Mathematical Definitions (Introduction to Video and Image Processing) Part 1

This topic provides some basic mathematical definitions. The topic is intended for readers who do not have a mathematical background or readers who need a “brush-up”.

Absolute Value

The absolute value of a number, z, is written as Abs(z) or |z|. It is calculated by deleting the “minus” in front of the number. This means that | —150| = 150. Mathematically the absolute value of a number, z, is calculated as

tmp7470-150_thumb

In terms of programming it can be written as

tmp7470-151_thumb

min and max

The min value of a set of numbers is written as min{xi,x2,—,x«} and simply means the smallest number in the set. For example, min{7, 3, 11,2,42} = 2. The max value of a set of numbers is written as max{x1,x2,…,x„} and simply means the biggest number in the set. For example, max{7, 3, 11, 2,42} = 42. In terms of programming the max operation can be written as follows, where we assume that N numbers are present in the list and that they are stored in list[]:


tmp7470-152_thumb

Table B.1 Different rational numbers and three different ways of converting to integers

X

Floor of x

Ceiling of x

Round of x

3.14

3

4

3

0.7

0

1

1

4.5

4

5

5

-3.14

-4

-3

-3

-0.7

-1

0

-1

-4.5

-5

-4

-4

Converting a Rational Number to an Integer

Sometimes we want to convert a rational number into an integer. This can be done in different ways, where the three most common are:

Floor simply rounds a rational number to the nearest smaller integer. For example: Floor of 4.2 = 4. Mathematically it is denoted |_4.2J = 4. In C-programming a build-in function exists: floor().

Ceiling is the opposite of floor and rounds off to the nearest bigger integer. For example: Ceiling of 4.2 = 5. Mathematically it is denoted [4.2] = 5. In C-programming a build-in function exists: ceil().

Round finds the nearest integer, i.e., Round of 4.2 = 4 and Round of 4.7 = 5. In terms of C-code the following expression is often used: int(x + 0.5). That is, we add 0.5 to the number and then typecast it to an integer.

In Table B.1 some examples are provided.

Summation

Say you want to add the first 12 positive integers:

1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 = 78    (B.2)

This is no problem writing down, but what if you want to add the first 1024 positive integers? This will be dreadful to write down. Luckily there exists a more compact way of writing this using summation, which is denoted as Σ. Adding the first 1024 positive integers can now be written as

tmp7470-153_thumb

where i is the summation index. Below the summation sign we have i = 1, which means that the first value of i is 1. Above the summation sign we have 1024. This actually means i = 1042, but we virtually always skip i =. Either way, it means that the last value of i is 1042. You can think of i as a counter going from 1 to 1042 in steps of one: 1, 2, 3,4, 5,…, 1040,1041, 1042. What comes after the summation is a function, which is controlled by i and it is the values of this function (for each i ) that are added together. Below, some examples of different summations are given:

tmp7470-154_thumb

Say that you want to sum the pixel values of the first row in an image with width = 200. This is then written as

tmp7470-155_thumb

In general the summation is written as

tmp7470-156_thumb

In terms of C-programming the summation is implemented as a for-loop:

tmp7470-157_thumb

We can also do a summation using more indices than i. For example, if we want to add all pixel values in an image, then we need two indices representing rows and columns. Concretely we would write

tmp7470-158_thumb

where N is the number of columns and M is the number of rows. In terms of C-programming the double summation is implemented as two for-loops:

(a) Point representation. (b) Vector representation

Fig. B.1 (a) Point representation. (b) Vector representation

tmp7470-160_thumb

Vector

In the 2D coordinate system in Fig. B.1 a point is defined as P(x1 ,y1 ). The same point can be represented as a vector:

tmp7470-161_thumb

A vector is often written as a lowercase letter with an arrow above. It can be interpreted as a line with a slopetmp7470-162_thumband a length. The length of the vector is defined as

tmp7470-164_thumb

We can arrange the vector as a row (as opposed to a column) by taking the transpose of the vector,tmp7470-165_thumbThat is,

tmp7470-167_thumb

or in other words:

tmp7470-168_thumb

Say we have two vectors:tmp7470-169_thumbWe  can then calculate the sum of  and p2 as

(a) Adding two vectors. (b) Subtracting two vectors

Fig. B.2 (a) Adding two vectors. (b) Subtracting two vectors

The angle between two vectors

Fig. B.3 The angle between two vectors

tmp7470-173_thumb

In the same way we can calculate the difference oftmp7470-174_thumbas

tmp7470-176_thumb

These operations can also be interpreted geometrically as illustrated in Fig. B.2.

Two vectors cannot be multiplied but we can calculate the dot product between them. Say we definetmp7470-177_thumbThe dot product between them is then defined as

tmp7470-179_thumb

The dot product can also be interpreted geometrically as

tmp7470-180_thumb

wheretmp7470-181_thumbis the length of vectortmp7470-182_thumbis the length of vectortmp7470-183_thumband V is the angle between the vectors, see Fig. B.3. Note that it is always the smallest of the two possible angles that is calculated using Eq. B.16, i.e., 0° < V < 180°. The biggest angle is found as Vbig = 360° — V.

B.6    Matrix

When we have multiple vectors we can represent them as one entity denoted a matrix. For example,tmp7470-184_thumbcan be represented as

tmp7470-189_thumb

A matrix is often denoted by an uppercase letter in boldface, but other representations can also be used.

We say a matrix has a vertical and horizontal dimension, e.g., P has dimension 2 x 2. Note that the dimensions need not be equal. Similar to a vector a matrix can also be transposed by making the columns into rows:

tmp7470-190_thumb

Matrices can be added and subtracted similar to vectors, but they need to have the same dimensions:

tmp7470-191_thumb

Matrices can be multiplied in the following way:

tmp7470-192_thumb

The entry in row one and column one of the output matrix (ae + cf ) is found as the dot product between row one of the left matrix and column one of the right matrix. This principle is then repeated for each entry in the output matrix. This implies that the number of columns in the left matrix has to be equal to the number of rows in the right matrix. On the other hand this also implies that the number of rows in the left matrix and the number of columns in the right matrix need not be the same. For example, a matrix can be multiplied by a vector. The dimensions of the output matrix are equal to the number of rows in the left matrix and the number of columns in the right matrix. Below, some examples are shown:

tmp7470-193_thumb

A matrix of particular interest is the identity matrix, which in the 2D case looks like this:

tmp7470-194_thumb

If the product of two matrices equals the identity matrix, A · B = I, then we say they are each other’s inverse. This is denoted as A-1 = B and B-1 = A, or in other words A · A-1 = A-1 · A = I. For a 2 x 2 matrix the inverse is calculated as

tmp7470-195_thumb

Calculating the inverse for matrices of higher dimensions can be quite complicated.

Next post:

Previous post: