Image Processing Reference

In-Depth Information

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

B.3

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
.
2

=

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.

B.4

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

1024

i

(B.3)

i
=

1

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

=

. 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

=

1042, but we virtually always skip
i

=