Sei sulla pagina 1di 6

Forth International Conference on Intelligent Computing and Information Systems

March 19-22, 2009, Cairo, Egypt


380
Software Package for JPEG Compression Decompression
Ahmed A. Radwan
Computer Science Dept.
Faculty of science,
Minia University
Egypt
aaaradwan2008@yahoo.com
Ahmed Swilem
Computer Science Dept.
Faculty of science,
Minia University
Egypt
ahmed200eg@yahoo.com
Al-Hussien Seddik
Computer Science Dept.
Faculty of science,
Minia University
Egypt
Eng.hussien_seddik@yahoo.com
ABSTRACT
Data compression seeks to reduce the number of bits used to store
or Transmit information. Data-compression techniques can be
divided into two major families; lossy and lossless data
compression. In general, data compression consists of taking a
stream of symbols and transforming them into codes. If the
compression is effective, the resulting stream of codes will be
smaller than the original symbols [9].One of the most important
compression branches is image compression .Image compression
consists in reducing information volume representing an image
[1]. One of the most popular and comprehensive image
compression standards is the JPEG [13].JPEG is an image
compression standard developed by Joint Photographic Experts
Group [16]. This paper presents a software package for JPEG with
many options as it allows the user to control in the compressed
image quality and size, JPEG Encoding / Decoding that converts
the image into a compressed image file and also this package
contains a software for encrypting / decrypting an image by
adding some steps to the JPEG Encoding / decoding steps.
KEYWORDS
Image Compression, JPEG, RGB, DCT, Entropy Encoding
1. INTRODUCTION
Nowadays, multimedia applications use vast number of images.
Large number of high-quality images requires high capacity mass-
storage devices and high transmission bandwidth if stored and
transmitted in uncompressed bitmap form [8].
To reduce storage space or transmission cost image compression
is the solution [3]. The purpose of image compression is to
represent images with less data volume in order to save storage
costs or transmission time and costs [12].
Image compression means representing an image with smaller
number of bits without introducing appreciable degradation of
visual quality of decompressed image [3].Elimination of
redundancies and non-pertinent information enables memory
space minimization and thus faster data transmission [1]. But on
the other hand, the reconstructed images may be very bad when
high compression ratio is required [14].
There are two main categories for image compression lossless and
lossy. Lossless compression is an error free compression. The
recovered image is numerically as the same as the original image,
on a pixel by pixel basis [11] .Despite this excellent feature, only
a small amount of compression is possible and hence the obtained
compression ratio is low. For some applications, lossless
compression technique is the only acceptable method of data
reduction. These kinds of applications tolerate no loss in
information and include : archival of medical images where the
loss of any information is not tolerated because it may affect the
diagnostic accuracy , archival of business documents where losing
information is illegal .[11] .Lossy image compression such as jpeg
is based on compressing the accuracy of the recovered image in
exchange for more compression .The reconstructed image
contains distortion , which may or may not be visually apparent
[11] . It does not reconstruct the original image bit-by-bit [8].
There are two important lossy compression approaches: vector
quantization method and transform method [11]. The general
components of a lossy image compression technique are shown in
fig. 1.From [11].
Figure 1. General components for a lossy compression
technique.
As shown in Figure 1 .The first stage is the image decomposition
or transformation .The purpose of this stage is to produce a more
efficiently code representation of image data. The second stage is
quantization and it aims to reduce the number of possible output
symbols. The type and degree of quantization has a significant
effect on the quality of the reconstructed image. The third stage is
symbol encoding, which may or may not be included in the
process, depending on the lossy technique used [11]. This paper is
organized as follows:
Section 2 briefly introduces the JPEG compression principles and
the JPEG encoding steps. Section 3 introduces our software
package with a lot of figures that shows the forms of the program.
Section 4 shows the experimental results of our software package
for the compression programs and the encode program. Section 5
presents the conclusion.
Compressed
image file
Original
Image
Symbol encoding
Quantization
Decomposition
or
Transformation
Forth International Conference on Intelligent Computing and Information Systems
March 19-22, 2009, Cairo, Egypt
381
(1)
(2)
(3)
2. JPEG COMPRESSION
JPEG is the most popular image compression technique used
currently [8]. It consists of a lot of steps as shown in Figure 2
[17].
2.1 JPEG Encoding
As shown in Figure 2 .The encoding process of the JPEG starts
with color-space conversion [8]. The RGB image is converted into
YIQ, YUV or YCBCR. Because these planes have less inter
correlation among the triplet than RGB [6]. Among these color-
spaces YIQ is the most popular in color image transmission and is
used in color TV broadcasting [3]. An RGB represented color
image can be converted to YIQ coordinates as follows [5]:
Here, as shown in (1) .Y is the luminance or brightness, I is the
hue, and Q is the saturation or depth of color. Y represents the
black and white image. I and Q contain the additional information
used to produce color images. For this reason, I and Q together are
sometimes referred to as chrominance values [5].The process of
conversion is not applicable to gray-scale image, where there is
only one luminance component for gray-scale image. Color image
data in computers is usually represented in RGB (Red-Green-
Blue) format [8]. Encoding a color image then consists of
converting an RGB image to YIQ coordinates, decimating Y, I
and Q and then applying a gray-scale compression algorithm such
as JPEG to each of the Y, I, and Q coordinates [5]. The next
process is the forward DCT (Discrete Cosine Transform)
operation. It is a mathematical operation which transforms the
input data in 8x8
Pixels block units from original space domain to spatial frequency
domain [2].
The DCT Equation [2]:
Where
This operation de-correlates the image data to reduce redundancy
of data, which will contribute to compression of image data. In
general, neighboring pixels within an image tend to be highly
correlated. Storing correlated data is a redundancy [8]. The output
from this operation will be the DCT coefficients. The next
operation is quantization. This operation is the major reason for
losses in JPEG images. Each coefficient data from DCT operation
is divided with a constant value referred from quantization table
resulting to smaller value [8].
The quantization tables [2]:
The quantization equation [16]:
Here, in (3), FQ (u, v) represents the quantized DCT coefficients
rounded to the nearest integer, F (u, v) represents the DCT
coefficients, and Q (u, v) represents the quantization matrix [17]
as shown in Figure 3.
More efficiency can be gained by reordering the quantized DCT
coefficients. Since most of the non-zero DCT coefficients will
Figure 2. JPEG encoding steps
Figure 3. Quantization tables for luminance and
chrominance
Forth International Conference on Intelligent Computing and Information Systems
March 19-22, 2009, Cairo, Egypt
382
Figure 7. Decoding Form
Figure 6. Encoding Form
typically be concentrated in the upper left-hand corner of the
matrix, it is apparent that a zigzag scanning pattern as shown in
Figure 4 from upper left corner to lower right corner will tend to
maximize the probability of achieving long runs of consecutive
zero coefficients [8].
The first coefficient (upper left one) in the zigzag sequence is the
DC coefficient, Remaining 63 coefficients are AC coefficients
[10].
DC coefficient and AC coefficients are coded separately. The DC
coefficient is coded using DPCM (Differential Pulse Code
Modulation) [1] model, while AC coefficients are coded using
(RLE) [1] run-length coding model. Both coding models are
lossless [8]. The final stage of JPEG encoder is entropy coding
[8]. Entropy coding is lossless compression. There are two
entropy coding schemes defined in JPEG algorithm - Huffman
coding and Arithmetic coding. Most JPEG encoders use Huffman
coding [8], because Huffman coding technique is very simple and
effective [15].The resulting bit stream from entropy encoder is
stored or transmitted [8]. In order to obtain the original image
(Decompressed / reconstructed image) the encoding steps are
reversed, these steps are called the decoding steps [1].
3. OUR SOFTWARE PACKAGE
In this section we will present our software package and the
programs included. We will explain how to use this software
package and we will also describe briefly every tool in each
program.
This software package uses the JPEG approach and makes it easy
to be used and controlled with a lot of options. It consists of
encoder, decoder, encryption, decryption and two compression
programs that allow the user to choose the program he wants and
control in the reconstructed image quality and size.
Firstly, we will present the main form in our software package
that is shown in Figure 5.
As shown in Figure 5.It is consists of the following:-
1- Encode Image Button: show the encoding program.
2- Encrypt Image Button: show the encryption program.
3- Decode Image Button: show the Decoding program.
4- Decrypt Image Button: show the Decryption program.
5- Compression button: show the Compression programs.
6- Exit Button: to terminate (Exit) the program.
The next figure will be the encoding form, shown in Figure 6.
As shown in Figure 6. It contains the following:-
1- Help Menu: contains the How to Use option that helps
the user to use this program and explaining the entire
program's buttons, functions, etc..
2- File Menu: contains the Exit option that terminates the
program.
3- Picture Box: this box is used to view the image which
selected by the user.
4- Progress Bar: showing the progress of the encoding
process.
5- Load Image Button: allows the user to select the image
to be encoded.
6- Clear Image Button: is used to clear (initialize) the
picture box, the encoding report and the progress bar.
7- Encode Image Button: is used to encode the image
appears in the picture box using JPEG Encoding.
8- Back Button: allows the user to return to the previous
form (Main form).
9- Encoding Report: contains information about the
selected image before encoding, the image file after
encoding, the encoding time and the compression ratio.
The next figure will be the decoding form, as shown in Figure 7.
Figure 5. First form in our software package
Figure 4. Zigzag scan order
Forth International Conference on Intelligent Computing and Information Systems
March 19-22, 2009, Cairo, Egypt
383
Figure 10. Compression Form 1
As shown in Figure 7. It contains the following:-
1- Help Menu: contains the How to Use option that helps
the user to use this program and explaining the entire
program's buttons, functions, etc..
2- File Menu: contains the Exit option that terminates the
program.
3- Picture Box: this box is used to view the decoded
image.
4- Progress Bar: showing the progress of the decoding
process.
5- Load Image File Button: allows the user to select the
image file to be decoded.
6- Decode Image File Button: is used to decode the image
file that is selected by the user using JPEG Decoding.
7- Clear Image Button: is used to initialize the form.
8- Back Button: allows the user to return to the previous
form (Main form).
9- Decoding Report: contains information about the
selected image file before Decoding, the image after
decoding and the decoding time.
The next figure will be the Encryption form, as shown in Figure 8.
As shown in Figure 8. It contains the following:-
1- Help Menu: contains the How to Use option that helps
the user to use this program and explaining the entire
program's buttons, functions, etc..
2- File Menu: contains the Exit option that terminates the
program.
3- Picture Box: this box is used to view the image which
selected by the user.
4- Progress Bar: showing the progress of the encryption
process.
5- Load Image Button: allows the user to select the image
to be encrypted.
6- Clear Image Button: is used to clear (initialize) the
picture box, the encryption report and the progress bar.
7- Encrypt Image Button: is used to encrypt the image that
appears in the picture box using a password chosen by
the user.
8- Back Button: allows the user to return to the previous
form (Main form).
9- Image Report: contains information about the selected
image path, encrypted file path and the encryption time.
The next figure will be the decrypt form, as shown in Figure 9.
As shown in Figure 9. It contains the following:-
1- Help Menu: contains the How to Use option that helps
the user to use this program and explaining the entire
program's buttons, functions, etc..
2- File Menu: contains the Exit option that terminates the
program.
3- Picture Box: this box is used to view the decrypted
image.
4- Progress Bar: showing the progress of the decryption
process.
5- Load Image File Button: allows the user to select the
image file to be decrypted.
6- Decrypt Image File Button: is used to decrypt the image
file using the password.
7- Clear Image Button: is used to clear (initialize) the
picture box, the decryption report and the progress bar.
8- Back Button: allows the user to return to the previous
form (Main form).
9- Image Report: contains information about the selected
image file before Decryption, the image after decryption
and the decryption time.
The next form will be the Compression form 1, as shown in
Figure 10.
Figure 8. Encrypt Form
Figure 9. Decrypt Form
Forth International Conference on Intelligent Computing and Information Systems
March 19-22, 2009, Cairo, Egypt
384
Figure 11. Compression Form 2
Table1. Results for the Encoding program
As shown in Figure 10. It contains the following:-
1- Help Menu: contains the How to Use option that helps
the user to use this program and explaining the entire
program's buttons, functions, etc..
2- File Menu: contains the Exit option that terminates the
program.
3- Original Picture Box (Left): this box is used to view the
selected image.
4- Progress bar: showing the progress of the compression
process.
5- Original Image Report: contains information about the
selected image before compression (original image).
6- Compression Report: contains information about the
compression time, type, and ratio, MSE, PSNR and
SNR.
7- Load Image Button: allows the user to select the image
to be compressed.
8- Clear Image Button: is used to clear (initialize) the
picture boxes, the reports and the progress bar.
9- Compress Image Button: allow the user to choose the
compression type (Very Low, Low Extremely High),
to compress the selected image.
10- Back Button: allows the user to return to the previous
form (Main form).
11- Compressed Picture Box (Right): is used to view the
compressed image.
12- Compressed Image Report: contains information about
the image after compression (compressed image).
The last form is the Compression form 2, as shown in Figure 11.
As shown in Figure 11. It contains the following:-
1- Help Menu: contains the How to Use option that helps
the user to use this program and explaining the entire
program's buttons, functions, etc..
2- File Menu: contains the Exit option that terminates the
program.
3- Original Picture Box (Left): this box is used to view the
selected image.
4- Progress Bar: showing the progress of the compression
process.
5- Show Report Button: shows the information in the
compression report.
6- Compression Report: contains information about the
compression time, ratio, original image size, and
compressed image size, MSE, PSNR and SNR.
7- Load Image Button: allows the user to select the image
to be compressed.
8- Clear Image Button: is used to clear (initialize) the
picture boxes, the reports and the progress bar.
9- Compress Image Button: allow the user to choose the
compression level by using 2 track Bars one for
luminance channel and one for chrominance channel, to
compress the selected image.
10- Back Button: allows the user to return to the previous
form (Main form).
11- Compressed Picture Box (Right): is used to view the
compressed image.
4. EXPERIMENTAL RESULTS
In this part we will present the results of our software package,
these results include image size before and after encoding and
compression, MSE (Mean Square Error), SNR (Signal To Noise
Ratio) and PSNR (Peak-to-Peak Signal To Noise Ratio) [1].we
used here two test images Lena and pepper as shown in figure 12
with sizes 64 x 64, 128 x 128 and 512 x 512.
4.1 Encode / Decode Results
Table 1 shows the results of the encoding program. We used a lot
of images with different dimensions and this table contains some
results of what we obtained from our encoding program. These
results include MSE, SNR, PSNR and CR (Compression ratio),
between the image and the encoded image file.
4.2 Compression Results
Table 2 shows the results of the compression program. We used
the two test images shown in figure 12. This table will include
results as size of the image before and after compression, MSE,
SNR, PSNR and CR (Compression Ratio) between the original
image and the compressed image.
Dimensions Image
Size before
Encoding
(Kb)
File Size after
Encoding
MSE SNR
(db)
PSNR
(db)
CR %
64 x 64 Lena 12.0 596 bytes 9.9E-5 30.8 35.5 95.2
128 x 128 Lena 48.0 2.67 Kb 5.7E-5 33.7 37.9 94.4
512 x 512 Lena 768.0 32.9 Kb 2.8E-4 25.7 31.2 95.7
Forth International Conference on Intelligent Computing and Information Systems
March 19-22, 2009, Cairo, Egypt
385
Table 2. Results for the Compression program
Figure 12. Test images
5. CONCLUSION
This paper presents a software package for the JPEG approach
that allows the user to encode, decode, encrypt, decrypt and
compress images using 2 different programs. The user can choose
the program he wants to use and also he can control in the
reconstructed image quality and size using a lot of available
options that is easy to use. After our software package had been
tested by using the two images shown in Figure 12.It is found that
the package our software package presented good results. As
shown in Tables 1, 2, 3 the MSE is low and the PSNR of the
compressed and reconstructed images is high thats means the
difference between the 2 images is low while the compression
ratio is high.
6. REFERENCES
[1] A. Alkholidi, A. Alfalou, H. Hamam. new approach for
optical colored image compression using the JPEG
standards. Signal Processing 87 ,(2007) ,569583.
[2] Al Bovik.Hand Book Of Image And Video
Processing.2000.
[3] Bibhas Chandra Dhara, Bhabatosh Chanda. Color
image compression based on block truncation coding
using pattern fitting principle. Pattern Recognition 40
,(2007) ,2408 2417.
[4] Chin-Chen Chang, Tung-Shou Chen, Lou-Zo Chung. A
steganographic method based upon JPEG and
quantization table modification. Information Sciences
141, (2002) ,123138.
[5] Clifford Clausen, Harry Wechsler. Color image
compression using PCA and backpropagation learning.
Pattern Recognition 33, (2000), 1555-1560.
[6] Evgeny Gershikov, Emilia Lavi-Burlak, Moshe Porat.
Correlation-based approach to color image compression.
Signal Processing: Image Communication 22 ,(2007)
,719733.
[7] Jae Won Moon, Jong Seok Lee, Nam Ik Cho. A
requantization algorithm for the transcoding of JPEG
images. Signal Processing: Image Communication 21 ,(2006)
,1321.
[8] Koay Kah Hoe (M. Eng.). A JPEG Decoder IP Module
Designed Using VHDL Module Generator. Project
Paper, Faculty of Electrical Engineering, University of
Technology Malaysia, 2000.
[9] Mark Nelson, Jean-Loup Gailly.The Data Compression
Book .second edition.
[10] Nick Kingsbury. JPEG Entropy Coding. Version 2.4,
Jun 15, 2006 10:13 am GMT-5.
[11] Robrt y.li ,jung kim, N. Al-shamakhi .image
compression using transformed vector
quantization.image vision computing 20,(2002),37-45.
[12] T. Shohdohji, g. Hoshino and n. Kutsuwada.
Optimization of Quantization Table Based on Visual
Characteristics in DCT Image Coding. Computers and
Mathematics with Applications 37 ,(1999), 225-232.
[13] William K. Pratt. Digital image Processing. Fourth
edition .2007.
[14] Yi-Ming Zhou, Chao Zhang, Zeng-Ke Zhang. An
efficient fractal image coding algorithm using unified
feature and DCT. Chaos, Solitons and Fractals ,(2007) .
[15] Yu-Chen Hu, Chin-Chen Chang. A new lossless
compression scheme based on Huffman coding scheme
for image compression. Signal Processing: Image
Communication 16 ,(2000) ,367-372.
[16] Ze-Nian Li, Mark S Drew.Fundamentals of Multimedia .
[17] http://www.cs.cf.ac.uk/Dave/Multimedia//node234.html
Size Image
Original
image
size
(Kb)
Compressed
image size (Kb)
Compression Program
MSE
SNR
(db)
PSNR
(db)
CR %
64x64
Lena 12.0 1.26 1.9E-5 37.8 42.5 89.5
Pepper 12.0 1.29 0.0005 23.2 29.1 89.3
128x128
Lena 48.0 3.36 5.7E-5 33.1 37.6 93.0
Pepper 48.0 3.47 0.0006 21.6 28.1 92.8
512x512
Lena 768.0 27.4 0.0003 25.9 31.4 96.4
pepper 768.0 20.1 0.0007 20.7 27.2 97.2

Potrebbero piacerti anche