117
Other Signal and Image Processing Methods
following codes: 0 → 110, 1 → 1110, 2 → 1010, 3 → 11110, and 4 → 00. For this
code, the space needed to save the image is calculated as follows:
× × .
4 . + × .
5 0 07 + × 0 80
Size of image = 256 × 256 (3 0 05 + ×0 03 4 0 05 + × .
2 . )
= 12 ,
bit
23 965
As can be seen, there is a significant decrease on the amount of space needed to
save this image. Knowing that in biomedical applications, we need to store and
transmit very many large medical images, the importance of using some optimal
technique for binary representation of the biomedical data cannot be overestimated. Before describing the optimal technique for such an encoding and representation process, we have to add that in the literature of coding and information
theory, in order to have a general criterion for the goodness of a code, a concept
−
called the average length of the code, L, is defined as follows:
M −1
L = ∑ pl i i
(6.33)
i =0
In the preceding equation, l i and p i are the length and probability of the ith codeword, respectively. This definition, unlike the total size used earlier, is independent of the size of the image or file before encoding. In addition, it is known that
entropy in base 2 gives the theoretical limit on the average length of the best possible code. Therefore, it is desirable to compare the average code length of every
code with the entropy and explore the quality of the obtained code compared to
an optimal code. Such a measure is called “code rate” or “code efficiency” and is
defined as follows:
H
R =
(6.34)
L
In comparison of two sets of codes using the code rate, the code with larger core
rate (i.e., the core rate closer to one) provides a better code set.
6.5.3 HOFFMAN CODING
Hoffman coding is probably the best practical method of encoding the symbols with
known probabilities. The basic idea of this method is very straightforward: Give
longer codes to less probable symbols and shorter codes to more probable symbols.
This way, in average, Hoffman code reduces the storage space for the lossless encoding of information. The practical steps in forming Hoffman codes can be described
as follows:
Step 1: Take the two last probable gray levels.
Step 2: These two gray levels will be given the longest code word that differ
only in one last bit.
Step 3: Combine these two gray levels into a single symbol and repeat Steps
1 to 3.
Other Signal and Image Processing Methods
following codes: 0 → 110, 1 → 1110, 2 → 1010, 3 → 11110, and 4 → 00. For this
code, the space needed to save the image is calculated as follows:
× × .
4 . + × .
5 0 07 + × 0 80
Size of image = 256 × 256 (3 0 05 + ×0 03 4 0 05 + × .
2 . )
= 12 ,
bit
23 965
As can be seen, there is a significant decrease on the amount of space needed to
save this image. Knowing that in biomedical applications, we need to store and
transmit very many large medical images, the importance of using some optimal
technique for binary representation of the biomedical data cannot be overestimated. Before describing the optimal technique for such an encoding and representation process, we have to add that in the literature of coding and information
theory, in order to have a general criterion for the goodness of a code, a concept
−
called the average length of the code, L, is defined as follows:
M −1
L = ∑ pl i i
(6.33)
i =0
In the preceding equation, l i and p i are the length and probability of the ith codeword, respectively. This definition, unlike the total size used earlier, is independent of the size of the image or file before encoding. In addition, it is known that
entropy in base 2 gives the theoretical limit on the average length of the best possible code. Therefore, it is desirable to compare the average code length of every
code with the entropy and explore the quality of the obtained code compared to
an optimal code. Such a measure is called “code rate” or “code efficiency” and is
defined as follows:
H
R =
(6.34)
L
In comparison of two sets of codes using the code rate, the code with larger core
rate (i.e., the core rate closer to one) provides a better code set.
6.5.3 HOFFMAN CODING
Hoffman coding is probably the best practical method of encoding the symbols with
known probabilities. The basic idea of this method is very straightforward: Give
longer codes to less probable symbols and shorter codes to more probable symbols.
This way, in average, Hoffman code reduces the storage space for the lossless encoding of information. The practical steps in forming Hoffman codes can be described
as follows:
Step 1: Take the two last probable gray levels.
Step 2: These two gray levels will be given the longest code word that differ
only in one last bit.
Step 3: Combine these two gray levels into a single symbol and repeat Steps
1 to 3.
