Image Processing Reference

In-Depth Information

The number of different values the coefficient can take is equal to the base, hence

for base-10, ten different values are possible
(
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
)
and for base-

2, two values are possible
(
0
,
1
)
.

Eight bits together is called a byte. A byte is shown as a row of eight bits (having

values 0 or 1). The bit to the left is called the most-significant bit (MSB) and the bit

to the right the least-significant bit (LSB). Converting a byte into a decimal number

is done by inserting the coefficients into the following equation (the eight right-most

termsofEq.
A.5
):

Decimal number

2
7

2
6

2
5

2
4

2
3

2
2

2
1

2
0

=
x
7
·

+
x
6
·

+
x
5
·

+
x
4
·

+
x
3
·

+
x
2
·

+
x
1
·

+
x
0
·

⇒

Decimal number

=

x
7
·

128

+

x
6
·

64

+

x
5
·

32

+

x
4
·

16

+

x
3
·

8

+

x
2
·

4

+

x
1
·

2

+

x
0

Some example byte values:

Binary

Decimal

00000000

0

00000001

1

00000010

2

00000100

4

00000101

5

00001111

15

00010101

21

01010101

85

10000000

128

11111111

255

As can be seen a byte is defined to have values from 0 to 255 (256 values in total).

Sometimes bytes are also appended to create numbers larger than 255. A common

example is two bytes together that spans the values 0

65535 (2
16

−

=

65536 in total).

A.1

Conversion from Decimal to Binary

A simple routine exists for getting the binary representation of a decimal number.

Initially, the largest power of two that is less than the decimal number is found. If the

decimal number is 137, the largest power of two is 128 (2
7
). This is then subtracted

from the original number and the corresponding bit is set. This is repeated until the

decimal number is reduced to zero. In our example, 137 is found to be a sum of

128, 8, and 1 and therefore the binary representation of 137 is 10001001. Another

example: