Implementation Challenges and Performance Analysis of Image Compression Using Huffman Encoding and DCT Algorithm On DSP Processor TMS320C6748 and Arduino Nano 33 BLE
Implementation Challenges and Performance Analysis of Image Compression Using Huffman Encoding and DCT Algorithm On DSP Processor TMS320C6748 and Arduino Nano 33 BLE
Abstract—To strike a compromise between compression some distortion in the reconstructed images but, as we will
ratio and image quality, this work focuses on a complete see in a moment this distortion level can be altered throughout
approach to image compression that combines Huffman coding the compression process. The JPEG technique is applied to
(HC) and discrete cosine transform (DCT). The mathematical both colour and monochrome photographs. There are two
underpinnings of DCT and practical applications are examined, main types of image compression: lossless and lossy. While
with a focus on how well it reduces redundancy. To further in lossy compression the rebuilt image may show degradation
improve compression effectiveness, the project incorporates the in comparison to the original, with lossless compression the
entropy coding process known as Huffman coding after the DCT
reconstructed image post-compression stays numerically
phase. By giving shorter codes to symbols that appear
frequently, Huffman coding enhances the representation of identical to the original. Using lossy techniques during the
altered visual data. The paper covers optimization strategies compression or decompression stages naturally results in a
and design concerns for using Huffman coding with Discrete reduction of image quality. In general, lossy algorithms
Cosine Transform. The study evaluates image compression provide larger compression ratios than lossless ones.
techniques employing DCT and HC transforms to determine Different compression methods can be classified into these
superior outcomes in terms of peak signal-to-noise ratio (PSNR), groups [1]:
compression ratio, and root mean square error (RMSE) and to Lossless compression techniques:
perform image compression efficiently. a. Run Length Encoding
b. Huffman Encoding
Keywords— Discrete Cosine Transform, HC, Compression
Ratio, Redundancy, Image Fidelity, PSNR, RMSE. c. Arithmetic Encoding
d. Entropy Coding
I. INTRODUCTION e. Area Coding
Lossy compression techniques:
A digital image created by sampling and quantizing a a. Predictive Coding
continuous tone picture requires a significant amount of b. Transform Coding (DCT/FT/Wavelets)
storage space. For instance, a 512×512 which is a 24-bit Lossless and lossy compression are the two categories into
colour image will use 768 kilo bytes of disk storage. Two which compression falls. When compression is done without
images at this speed would not fit on a single floppy disc. An sacrificing quality, the reconstructed image is numerically
image of such size would take over four minutes to send over identical to the source image. When a picture is reconstructed
a 28.8 Kbps modem, there are differences in the techniques using a lossy compression approach, there is a degradation
used to compress images. Compression techniques are often from the original. Each time an image is compressed or
divided into two classes: lossy and lossless compression. HC decompressed using a lossy approach, the quality of the
is already used in conferencing systems like H.263 as well as image is reduced. Generally, lossy methods offer a higher
text, picture, and video compression systems like JPEG, compression ratio than lossless methods.
MPEG-2, and MPEG-4. Video compression and Merits of HC:
conferencing systems such as JPEG, MPEG-2, MPEG-4, and A variable length coding technique called Huffman
H.263, etc. Using the Huffman coding approach, the distinct coding effectively encodes into a lesser number of bits. A
symbols are extracted from the original image, their lossless compression technique called Huffman coding
probability values are computed, and the symbols are ensures precise data restoration. DCT tends to concentrate a
arranged according to their probability values. With the significant amount of signal energy in low-frequency
Discrete Cosine Transform (DCT) at its core, the JPEG coefficients, contributing to a more compact representation.
process is a popular method of lossy image compression. The By converting spatial information into frequency
DCT divides images into segments with different frequencies components, DCT reduces redundancy and captures
to function throughout the Quantization process. The word important visual information in the given image.
"lossy" comes from the discarding of less significant Demerits of HC: Huffman coding’s adaptability may be
frequencies where compression takes place. Then, only the impacted by the complexity introduced by real-time
most important frequencies that remain are used to restore the applications that must adjust to shifting symbol probabilities.
image during the decompression process. As a result, there is DCT-based compression is inherently lossy, leading to a
Authorized licensed use limited to: J.C. Bose University of Science and Technology YMCA Faridabad. Downloaded on November 06,2024 at 10:46:04 UTC from IEEE Xplore. Restrictions apply.
reduction in image quality, particularly in the widely used to each reduced source, beginning with the smallest source
Joint Photographic Experts Group (JPEG), format. and working your way up to the source, is the next stage in
Huffman's algorithm. For a two-symbol source, the least
II. METHODOLOGY length binary codes are typically assigned as '0' and '1'.
A. Description of Huffman algorithm: These codes are arbitrarily allocated to the two symbols on
The two observations form the basis of the HC method. the right in Fig.3, and the order can be changed without
Shorter code words are associated with symbols that occur changing the result. Since two symbols in the reduced
more frequently than those that occur less frequently, to source are combined to generate the reduced source symbol,
reduce the total bits. The length of the two symbols that the '0' used to code the reduced source symbol with a
appear the least often will be the same [2]. probability of 0.6 is assigned to both symbols. Extra '0' and
B. Block diagram of image compression and decompression: '1' are added to each to distinguish them. For each decreased
source, this process is continued until the source is reached.
The leftmost portion of Fig.3 represents the finished
Huffman code. The average code length is found by
multiplying the likelihood of the sign by the number of bits
used in its encoding and then taking the mean. This
calculation helps to determine how effective the HC
technique is. Here's how this is calculated using the entropy
formula(1) as follows:
Lavg = (0.4)×(1) +(0.3)×(2) + (0.1)×(3) + (0.1)×(4) +
(0.06)×(5) + (0.04)×(5) = 2.2 bits/symbol.
Entropy, H=-∑P(aj)log (P(aj)) (1)
Fig. 1. Diagram of image compression and decompression
Where, P(aj)=probability of bit aj after Huffman encoding.
The source's entropy is 2.14 bits/symbol, the resultant
Huffman coding efficiency is 2.14/2.2 = 0.973.
C. Discrete cosine transform compression and
decompression:
One method for lowering the storage and transmission
costs is image compression. The methods that are now in use
for compressing image data can be broadly divided into two
groups: lossless and lossy methods. When using lossy
compression methods, the original digital image is typically
converted into a different domain where the transform greatly
decorrelates it, using an invertible linear transformation. The
significant visual information is condensed into a more
Fig. 2: Huffman source reduction. manageable form by this decorrelation. Following the
transformation, the coefficients are quantized to provide bit
streams with extended zero regions. It is possible to
efficiently code such bit streams to eliminate redundancy and
save them in a compressed file. To create the recovered
image, this process is reversed during the decompression. For
an N×N image, the matrix I (r, c) represents the pixel values.
where r represents the row-wise pixel and c represents the
column-wise pixel values[3], the 2-D DCT equation is given
by:
N −1N −1 (2r+1)uπ (2c+1)vπ
D(u, v) = α(u)α(v) I (r,c) cos[ ]cos[ ]
r =0 c=0 2N 2N
where N*N is the size of the given input image.
Fig. 3: Huffman code assignment procedure 1/ =0
α (u ), α (v) =
2/ =0
Symbols and accompanying probabilities are given in
descending order on the left side of the table. To produce a
compound symbol with a combined probability of 0.1, the where u=0,1,…N-1 along rows and v=0,1,…N-1
two smallest probabilities, such as 0.06 and 0.04, are along columns[1].
repeatedly combined [7]. The probabilities are then
guaranteed to stay in decreasing order by inserting this However, as the value of N increases, the computational
compound symbol in the "source reduction" column. Only complexity of the DCT operation increases. Hence to reduce
two probabilities 0.6 and 0.4 remain on the far right of the the complexity of the algorithm, DCT is performed in terms
table when the merger is complete. Assigning binary codes of predefined coefficient blocks. The equation of DCT in
SCEECS 2024
Authorized licensed use limited to: J.C. Bose University of Science and Technology YMCA Faridabad. Downloaded on November 06,2024 at 10:46:04 UTC from IEEE Xplore. Restrictions apply.
matrix form is represented using the below formula: between visual pleasure and compression. We used a Q50
matrix to generate a suitable compressed image.
SCEECS 2024
Authorized licensed use limited to: J.C. Bose University of Science and Technology YMCA Faridabad. Downloaded on November 06,2024 at 10:46:04 UTC from IEEE Xplore. Restrictions apply.
Fig. 9- Pixel values of the 8x8 sample image Fig. 13. Huffman Codes and redundancy of the image
After the thresholding operation, pixel values are as follows:
III. DEPLOYMENT ON TMSC320C6748 DSP PROCESSOR,
ARDUINO NANO 33 BLE, AND ISSUES FACED.
Texas Instruments created the high-performance, fixed-
point TMS320C6748 DSP processor. It is appropriate for a
variety of signal processing applications due to its C67x DSP
core [10], which has both fixed-point and floating-point
capabilities. The CPU offers flexibility in integrating with
other components by including multiple peripherals,
including GPIO, UART, I2C, SPI, and more [8].
A. Development Environment:
Code Composer Studio (CCS): The integrated
development environment for TMS320C6748, facilitating the
code development environment, debugging, and system
Fig.10. Pixel values of the image after analysis.TMS320C6748 evaluation board serves as the
applying a threshold on the given input image. hardware platform for testing and validating the implemented
After applying the DCT operation to the above image, the DCT algorithm. The limitation of this approach is due to the
resultant pixels are shown in Fig.11. limitations of the memory of the TMS320C6748 DSP
processor we should change from SHRAM to DDR2.
B. Issues faced during the implementation on the DSP
processor TMS320C6748:
1) The main problem during implementation is memory
allocation to the DSP Processor and we have to set the
memory for image processing as per the requirement as shown
in Fig.14, which is the C6748 file obtained in CCS.
SCEECS 2024
Authorized licensed use limited to: J.C. Bose University of Science and Technology YMCA Faridabad. Downloaded on November 06,2024 at 10:46:04 UTC from IEEE Xplore. Restrictions apply.
compression is a drawback. Because of the substantial The formulas used to calculate MSE and PSNR are:
redundancy in the image size, a compressed image utilizing
DCT cannot be exactly undone or decompressed to its
original condition. It is evident from the findings that there is
more than an 86 percent chance of the symbol ‘0’. As a result, Where m, n is the size of the original image.
the zero is allocated to a code word with the least number of 255 x255
bits, using the HC technique. It significantly lowers the PSNR ( db ) = 10 x log( )
MSE
amount of data needed to convey the size of the image. The Different performance metrics like PSNR, and MSE [4] of
JPEG standard makes use of the project's implemented both obtained images are shown in the TABLE I.
model. An 8-bit, 256×256 grayscale picture is used as the
input for this project's image compression model, which Parameter Cameraman’s Virat Kohli’s
mostly consists of the DCT and Huffman Coding blocks. image image
With Code Composer Studio (CCS) software, the entire Redundancy 65.67 64.13
image compression model is implemented on DSP Processor PSNR 7.18 dB 7.02 dB
TMS320C6748. The Huffman coding technique's
computational complexity is the reason for its
MSE 12457.18 dB 12913.88 dB
implementation to take so long time to complete. Numerous Compression 2.96 2.91
approaches for compression exist, such as the Fourier ratio
transform, wavelet transform, predictive coding, entropy- Below TABLE II. represents time taken to implement[6] and
based coding, and sub-sampling, each with its advantages and performance analysis of the proposed algorithm’s
disadvantages. Many techniques can be utilized depending on implementation on MATLAB, CCS, Arduino IDE platforms.
the requirements and level of redundancy needed. The
algorithm's experimental outcomes using several reference Size of input Time taken in Time taken on Time taken
photos are shown in the results. The results provided below image MATLAB TMS320C6748 on Arduino
illustrate the output produced using MATLAB and DSP BLE 33
TMS320C6748 board, Arduino Nano 33 BLE. The 128x128 0.324 sec 3.21 3.92
performance analysis of the compressed and decompressed 256x256 0.393 sec 4.68 6.62
images of Kohli and camera-man are obtained as shown in High-frequency components of the taken images are
Fig. 15 and Fig. 16. obtained as shown in the Fig.17.
Original image Output in DSP processor Output in MATLAB
Fig.15.The original, compressed images are obtained as Fig. 17. Results of images indicating high-frequency
shown in the above images. components, after the implementation on DSP using CCS.
Fig.16.A)Input image 16. B)Output image in CCS 16. C)Output image in Matlab
MATLAB MATLAB The results in Fig.18 are obtained on MATLAB, and DSP
after implementation of algorithm on 128x128 size images.
Input image Output Image in CCS Output Image in
MATLAB
SCEECS 2024
Authorized licensed use limited to: J.C. Bose University of Science and Technology YMCA Faridabad. Downloaded on November 06,2024 at 10:46:04 UTC from IEEE Xplore. Restrictions apply.
B. Output results obtained after applying the DCT algorithm, V.CONCLUSION
Huffman coding on the input image in C++ compiler: In the previous section, the output results of the algorithm
were detailed. The algorithm estimated a compression ratio
and successfully compressed the images. Its main benefit is
that it can achieve a higher compression ratio. We used CCS
to process the algorithm, connecting it to the DSP processor
(TMS320C6748), Arduino nano 33 ble to retrieve and
validate the output results obtained. Through the definition of
the 2D-DCT, we developed a hardware implementation
strategy. By measuring metrics like PSNR, and SNE,
applying Discrete Cosine Transform, and Huffman coding
algorithms, and examining the redundancy produced by the
suggested approach, a comprehensive assessment was
attained and image compression was done efficiently.
VI. FUTURE SCOPE
Future extensions hold great promise through the integration
of diverse methodologies. By exploring the synergy between
your current strategy and other image compression methods
or algorithms, we can envision a hybrid solution that
leverages the strengths of multiple approaches. This approach
employs efficient techniques for data compression and
optimization across diverse hardware platforms. We can
come up with a pure parallel architecture for efficient
hardware usage. The goal is to ensure a seamless integration
that not only preserves the essence of the current strategy but
also enhances its performance and adaptability. Overall, the
study contributes to image compression techniques.
VII. ACKNOWLEDGMENT
This work is supported by the Science and Engineering
Research Board (SERB) India, under the Grant of
EEQ/2021/001087.
REFERENCES
[1] Anjali Kapoor, Renu Dhir, Department of computer science and
engineering, “Image Compression Using Fast 2-D DCT Technique”,
National Institute of Technology, Jalandhar, India, IJCSE.
[2] Rahul Shukla and Narender Kumar Gupta, “Image Compression
through DCT and Huffman Coding”, International Journal of Current
Engineering and Technology, Vol. 5, No. 3, June 2015.
[3] N. Ahmed, T. Natarajan, K.R. Rao (1974), “Discrete Cosine
Transform”, IEEE Transaction on Computers, 100(1), pp.90-93, India.
[4] W. Yan, P. Hao, C. Xu, “Matrix factorization for fast DCT algorithms”,
Fig.20(A)On TMS320C6748 B.On Arduino Nano 33 BLE IEEE International Conference on Acoustics, Speech, and Signal
Processing, vol. 3, 2006.
Fig. 20(A), and Fig.20(B)shows the procedure of setting up [5] Nidhi Dhawale, “Implementation of Huffman algorithm and study for
the DSP, coding in CCS and Arduino Nano, coding in IDE. optimization”, Mtech VLSI Design, Department of Electronics, Shri
Ramdeobaba College of Engineering and Management, India,
International Conference on Advances in Communication and
B. Implementation of DCT, IDCT algorithm in MATLAB: Computing Technologies (ICACACT 2014).
[6] Viswanatha, “Implementation of tiny machine learning models on
Arduino 33 ble for gesture and speech recognition”, Journal of Xi'an
University of Architecture & Technology, ISSN.No:1006-7930, India.
[7] K. Ashok Babu, V. Sathish Kumar, “Implementation of data
compression using Huffman coding ”, 2010 International Conference
on Methods and Models in Computer Science (ICM2CS-2010).
[8] Qiang Wu, Tao Song, Xuwen Li, “High-Speed Image Acquisition and
Storage Technology based on TMS320C6748”, 4th National
Conference on Electrical, Electronics and Computer Engineering
(NCEECE), January 2016.
[9] Er. Abhishek Kaushik et al., “Image Compression Algorithms Using
Dct”, Int. Journal of Engineering Research and Applications.ISSN:
2248-9622, Vol. 4, Issue 4(Version 1), pp. 357-364, April 2014.
[10] Jing Zeng, “Design of Image Processing System Based on DSP Core”,
Fig.21.The output image after applying the inverted DCT IEEE 5th International Conference on Electronics and Communication
algorithm in MATLAB. Engineering (ICECE), China, December 2022.
SCEECS 2024
Authorized licensed use limited to: J.C. Bose University of Science and Technology YMCA Faridabad. Downloaded on November 06,2024 at 10:46:04 UTC from IEEE Xplore. Restrictions apply.