• No results found

Windowed Huffman Coding with Limited Distinct Symbols

N/A
N/A
Protected

Academic year: 2021

Share "Windowed Huffman Coding with Limited Distinct Symbols"

Copied!
6
0
0

Loading.... (view fulltext now)

Full text

(1)

Procedia Technology 4 ( 2012 ) 589 – 594

2212-0173 © 2012 Published by Elsevier Ltd. doi: 10.1016/j.protcy.2012.05.094

C3IT-2012

Windowed Huffman Coding with limited distinct symbols

Utpal Nandi

a

, Jyotsna Kumar Mandal

b

aDept. of Computer Sc. & Engg., Academy of Technology,Hooghly-712121,

West Bengal, India.

bDept. of Computer Sc. & Engineering, University of Kalyani, Nadia –741235,

West Bengal, India.

Abstract

The adaptive Huffman coding with a window of limited distinct symbols is proposed. The window buffer is used to store a specified number of distinct symbols most recently processed. The total number of symbols within the window may vary, but number of distinct symbols does not exceed a specified value. The adaptive Huffman tree is constructed based on the probability distribution of symbols within the window. Then, a variant of the proposed method is introduced. The proposed variant uses two windows. A small primary window buffer is used to store the most recently processed symbols. A comparatively large secondary window buffer is used to store more past processed symbols. The two separate Huffman tree are constructed based on the probabilities of symbols within the two windows. A symbol is encoded using first Huffman tree if it is found in the first window. Otherwise, the symbol is encoded using second Huffman tree if it is found in the second window. The first proposed technique comparatively offers better results than its counterpart for most of the file type. The performance of the second proposed technique is also close to the other techniques.

© 2011 Published by Elsevier Ltd. Selection and/or peer-review under responsibility of C3IT Keywords: Data compression, Huffman tree, Frequency Table (FT), Symbol Code Table (SCT), compression ratio;

1. Introduction

Variable length coding such as Huffman coding [5] is a two pass algorithm. In first pass, the probabilities of symbols are obtained. In the second pass, shorter codes are assigned to high probability symbols and longer codes to low probability symbols. But, the problems of this static Huffman coding and its variants [1,2,3,7] are the overhead of time to scan the symbols twice of the file and the overhead of frequency table transmission. These problems are eliminated in dynamic Huffman coding [6,8,9]. The one pass dynamic Huffman coding uses probabilities of symbols in already encoded symbols to construct Huffman tree and it does not require transmitting frequency table. The problem of dynamic Huffman

Open access under CC BY-NC-ND license.

(2)

algorithm is that it counts the number of occurrences of symbols in the entire encoded data. But, the probability distribution of symbols is different in different segment of the source data and changes during encoding. The better algorithm should forget the out of date symbols to obtain a more accurate probability distribution of the current segment of source data. A few numbers of variant are available to enhance the performance of dynamic Huffman coding. Some effective variants are Residual Huffman algorithm [10] and its improved version Windowed Huffman coding [4]. Windowed Huffman coding forgets the out of date symbols by using a fixed-size window buffer. The window buffer stores recently encoded symbols. The encoding process starts with empty window and Huffman tree contains the 0-node only. For each input symbol, the weight of the corresponding node is increased and the Huffman tree is adjusted to maintain the sibling property and invariance. Then, the symbol is kept into the window buffer. If the window is full, the oldest symbol of the window is removed and the weight of the node associated to the removed symbol is decreased and the Huffman tree is adjusted. But, there are some limitations of the Windowed Huffman coding that is discussed in section 2. To overcome such limitations, two new compression techniques are proposed in section 3. The results have been given in section 4 and the conclusions are drawn in section 5. The references are noted at end.

2. Limitations of Windowed Huffman coding

As the number of distinct symbols in the window increases, the depth of Huffman tree based on the symbols of window also increases. As the largest code length being used to represent a symbol is directly proportional to the height of the tree, is also increases. In the worse cases the highest code length for a symbol will be (number of distinct symbols - 1) bits. For example, let the window buffer size (N) = 32 symbols containing six distinct symbols P, Q, R, S, T, U. The frequency table, corresponding Huffman tree and symbol code table are shown in Table 1, Fig. 1 and Table 2 respectively. Symbol T and U are assigned codes of length five which are just one less than the number of distinct symbols within the window. Using such large codes for symbols are a sign of inefficient coding even they have comparatively lower frequencies. So, it may be concluded that in such case Window Huffman coding offers poor performance. Another problem is that Windowed Huffman algorithm uses fixed size window. The performance of the algorithm depends on the size of the window. Because, the optimal size of the window depends on the source data, it is hard to determine a suitable window size for all types of data. An adaptive version of the windowed Huffman algorithm adjusts window size by using different policies. But, the available policies are not able to determine the optimal window size during encoding.

Table 1. FT of window buffer

Symbol Frequency P 16 Q 8 R 4 S 2 T 1 U 1

(3)

Table 2. STC of symbols

Fig. 1. Huffman tree for Table 1

3. Proposed compression techniques

To overcome the above limitations of Windowed Huffman algorithm, two new variants are proposed as given in section 3.1 and 3.2.

3.1. Windowed Huffman algorithm with limited distinct symbols (WHDS)

This proposed WHDS algorithm also uses a window. But, the number of symbols within the window buffer is not fixed. It restricts the number of distinct symbols within the window buffer. Because, the code length of symbol depends on the number of distinct symbols, not the total number of symbols within the window, the proposed algorithm offers comparatively shorter code of symbols. If the number of distinct symbols exceeds a specified value, oldest symbol is removed repeatedly until the number of distinct symbols within the specified value. The procedure of the proposed algorithm is given in Fig. 2.

3.2. Windowed Huffman algorithm with more than one window (WHMW)

In previous proposed algorithm, a symbol to be encoded not in window is separated by ESCAPE code and then coded by 8 bit ASCII. To avoid such problem, a variant of the proposed algorithm is introduced and termed as Windowed Huffman algorithm with more than one window (WHMW). The proposed WHMW uses two window buffers. A primary window buffer keeps most recently encoded symbols. The secondary window keeps comparatively more encoded symbols. The proposed algorithm reduces the use of ESCAPE codes. If a symbol to be encoded is not in primary window, it may be in secondary window and coded with the help of a Huffman tree that is constructed by the symbols of the secondary window.

Symbol Frequency P 1 Q 01 R 001 S 0001 T 00001 U 00000

(4)

Otherwise, the ESCAPE code is used for the symbol. But, extra overhead is associated with the proposed algorithm to maintain two window buffers. The procedure of the proposed algorithm is given in Fig. 3.

Fig. 2. Windowed Huffman algorithm with limited distinct symbols

Fig. 3. Windowed Huffman algorithm with more than one window

Initially, the window buffer is empty and the Huffman tree is with a 0- node; While (not end of file/stream) do

Read the next symbol as new_symbol ; Encode {or decode} new_symbol; Update_increase (new_symbol) ;

Insert new_symbol into the window buffer;

If (Number of distinct symbols > specified value), then While (Number of distinct symbols > specified value) do Remove the oldest_symbol from window buffer ; Update_decrease (oldest_symbol);

End_while; End_if ; End_while; End;

Initially, the primary and secondary window buffers are empty. The Huffman tree for primary (H_tree1) and secondary (H_tree2) window are with a 0- node.

While (not end of file/stream) do Read the next symbol as new_symbol Encode {or decode} new_symbol; Update_increase (new_symbol, H_tree1) ; Update_increase (new_symbol, H_tree2) ;

Insert new_symbol into the both primary and secondary window buffers; If (Number of distinct symbols of primary window> specified value1), then While (Number of distinct symbols of primary window> specified value1) do Remove oldest_symbol from primary window;

Update_decrease (oldest_symbol, H_tree1); End_while;

End_if ;

If (Number of distinct symbols of secondary window> specified value2), then While (Number of distinct symbols of secondary window> specified value2) do Remove oldest_symbol from secondary window;

Update_decrease (oldest_symbol, H_tree2); End_while;

End_if; End_while; End;

(5)

4. Results

Comparison of compression ratios of different techniques with proposed WHDS , WHMW have been made as given in Table 3 where the compression ratio is calculated as ( 1 – compressed file size/input file size) x 100 %. The graphical representation of the same is shown in Fig. 4. The proposed WHDS coding offers better results for most of the file types like NTSC, Hybrid, Triff, C++ than other techniques. But, the performance is not so good for Doc file. The result of proposed WHMW is significant for Exe, NTSC, C++ files than its counterpart and closed to WHDS technique.

Table 3: Comparison of compression ratios in different techniques

Fig. 4. The graphical representation of Comparison of compression ratios in different techniques

5. Conclusion

The proposed WHDS algorithm uses a variable length window buffer to store limited number of distinct symbol to overcome the limitation of Windowed Huffman coding and constructs a adaptive Huffman tree based on the probability distribution of symbols in the window. The WHDS offers comparatively better compression ratio for most of the file type than Huffman, Adaptive Huffman and Windowed Huffman techniques. The proposed WHMW uses two window buffers and reduces the use of ESCAPE codes of

File name Huffman Adaptive Huffman Windowed Huffman Proposed WHDS Proposed WHMW Doc 41.3 41.5 40.4 40.9 40.5 Exe 18.2 18.9 20.1 20.4 20.2 Hybrid 29.9 30.1 42.5 43.2 41.7 Core 10.9 12.8 12.5 13.6 11.8 NTSC 20.4 20.5 29.4 31.1 30.2 Tiff 17.1 18.2 23.3 23.7 21.1 C++ 41.1 41.6 41.6 42.5 41.8

(6)

previous technique. But, extra overhead is associated to maintain two window buffers. The performance WHMW is close to the other techniques but not so well most of the time. The proposed techniques have a great scope of modification to enhance the performance and can be used for image compression also.

Acknowledgements

The authors extend sincere thanks to the department of Computer Science and Engineering and IIPC Cell, University of Kalyani, Nadia, West Bengal, India for using the infrastructure facilities for developing the technique.

References

1. Nandi, U., Mandal, J. K. Region based Huffman (RB H) Compression Technique with Code Interchange.

Malayasian Journal of Computer Science (MJCS), Malayasia, Vol. 23, No. 2, September 2010, p. 111-120. 2. Mandal, J. K., Kumar, A. A Compression Technique Based on Optimality of Huffman Tree (OHT). in Proceedings

of 12th International Conference of IEEE on Advanced Computing and Communications - ADCOM-2004,

December 15-18, 2004, Ahmedabad, India, p. 589- 595.

3. Mandal, J.K. and Gangopadhayay, R. Implementation of Two Data Compression Schemes. in Proc. First International Workshop on Telematics, NERIST, India,1995, p.154-162.

4. HUANG, H.-C., and Wu, J.-L. Windowed Huffman coding algorithm with size adaptation. IEE PROCEEDINGS-I, Vol. 140, No. 2; APRIL 1993, p. 109-113.

5. HUFFMAN, D.A. A method for the construction of minimum redundancy codes. Proc. IRE, 1952, (40), p. 1098-1 101.

6. FALLER, N . An adaptive system for data compression. Record of the 7th Asilomar Conference on Circuits, System,

and Computers, 1973, p. 593-597.

7. GALLAGER, R.G. Variations on a theme by Huffman.. IEEE Trans., 1978, IT-24, (6), p. 668-674. 8. KNUTH, D.E. Dynamic Huffman coding. J . Algorithms, 1985, (6), p 163-170.

9. VITTER, J.S. Dynamic Huffman coding. ACM Trans. Math. SoJt-ware, 1989, 15, (2), pp. 158-167

10. HUANG, H.-C., and Wu, J.-L. Design and analysts of residual Huffman algorith. National Computer Symposium,

Figure

Fig. 3. Windowed Huffman algorithm with more than one window
Table 3: Comparison of compression ratios in different techniques

References

Related documents

In 2006 and 2007, as part of my doctoral research which examined the journeys of Iraqi refugees from the Middle East to Australia, I interviewed Iraqi refugees in

The theory of Hilbert space of entire functions is a detailed description of eigenfunction expansions associated with formally selfadjoint differential operators, then one can

order mode, the coupling will be maximum. On the other hand, the loop-type decoupler magnetically couples with the dominant ground mode. The coupling is strong when a magnetic

Lines show human ear resolution ( just noticeable differences or difference limens ) of pure tones in both atoms and cents (see section ( 1.6 ) for more details) as a function

B ased on results of data research, application of science learning tools based on guided inquiry learning model to increase creative thinking skill of junior high school

The binary images generated by each iteration of the PCNN algorithm create specific signatures of the scene which are compared for the generation of the change

A tsunami as long wave and an oscillatory wave moves into shoaling water have behavior similar to solitary wave and therefore comprehension on its bottom boundary layer

Thus, tumor targeting and TME dual-responsive HA-shielded core–shell nanoparticles would be a potential platform for targeted co-delivery of chemotherapy drug and gene