SlideShare a Scribd company logo
INTEGRATED PROJECT REPORT
On
IMAGE COMPRESSION AND DECOMPRESSION
SYSTEM
Submitted in partial fulfillment of the requirement for the Course
Integrated Project-II (CSP2204) of
COMPUTER SCIENCE AND ENGINEERING
Batch-2014
in
May-2016
Under the Guidance of: Submitted By:
Ms. Ankita Tuteja Vishesh
1411981272
Shubham Kansal
1411981225
Vipin Kumar
1411981265
Vikrant Chaudhary
1411981261
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
CHITKARA UNIVERSITY
HIMACHAL PRADESH
ii
CERTIFICATE
This is to be certified that the project entitled “Image Compression and Decompression
System” has been submitted for the Bachelor of Computer Science Engineering at Chitkara
University, Himachal Pradesh during the academic semester January 2016- May 2016 is
bonafide piece of project work carried out by Vishesh (1411981272), Shubham Kansal
(1411981225), Vipin Kumar (1411981265) and Vikrant Chaudhary (1411981261) towards the
partial fulfillment for the award of course Integrated Project (CSP-2204) under the guidance of
Ms. Ankita Tuteja and supervision.
Signature of Project Guide
Ms. Ankita Tuteja
(Assistant Professor, CSE Department)
iii
CANDIDATE’S DECLARATION
We, Vishesh (1411981272), Shubham Kansal (1411981225), Vipin Kumar (1411981265) and
Vikrant Chaudhary (1411981261), B.E.-2014 of the Chitkara University, Himachal Pradesh
hereby declare that the Integrated Project Report entitled “Image Compression and
Decompression System” is an original work and data provided in the study is authentic to the
best of our knowledge. This report has not been submitted to any other Institute for the award
of any other course.
Sign. of Student 1 Sign. of Student 2 Sign. of Student 3 Sign. of Student 4
Vishesh Shubham Kansal Vipin Kumar Vikrant Chaudhary
1411981272 1411981225 1411981265 1411981261
Place:
Date:
iv
ABSTRACT
The compression and decompression of continuous-tone images is important in document
management and transmission systems. Image compression is the application of Data
compression on digital images. In effect, the objective is to reduce redundancy of the image
data in order to be able to store or transmit data in an efficient form. Therefore, the theory of
data compression becomes more and more significant for reducing the data redundancy to
save more hardware space and transmission bandwidth. In computer science and information
theory, data compression or source coding is the process of encoding information using fewer
bits or other information-bearing units than an unencoded representation. Compression is
useful because it helps reduce the consumption of expensive resources such as hard disk space
or transmission bandwidth and Decompression is useful when we take quality of images is
taken into consideration. In this project, we briefly introduce both image compression and
image decompression.
v
ACKNOWLEDGEMENT
It is our pleasure to be indebted to various people, who directly or indirectly contributed in the
development of this work and who influenced our thinking, behavior and acts during the
course of study.
We express our sincere gratitude to all for providing an opportunity to undergo Integrated
Project-II as the part of the curriculum.
We are thankful to “Ms. Ankita Tuteja” for her support, cooperation, and motivation provided
to us during the training for constant inspiration, presence and blessings.
Lastly, We would like to thank the almighty and our parents for their moral support and
friends with whom we shared our day-to day experience and received lots of suggestions that
improve our quality of work.
With Sincere Thanks,
Vishesh (1411981272), Shubham (1411981225), Vipin (1411981265), Vikrant (1411981261)
vi
TABLE OF CONTENTS
Page No.
Abstract iv
Acknowledgement v
List of Tables viii
List of Figures ix
Chapter 1: Introduction 1
1.1 Concept 2
1.2 Need of Compression 2
1.3 Image Compression 3
1.3.1 Advantages of Image Compression
1.3.2 Disadvantages of Image Compression
1.4 Image Decompression 3
1.4.1 Advantages of Image Decompression
1.4.2 Disadvantages of Image Decompression
1.5 Techniques used for Image Compression and De-Compression 4
Chapter 2: Literature Survey 8
Chapter 3: Methodology 10
3.1 Data Flow Diagram 12
3.2 Class Hierarchy 13
3.3 Software and Hardware Requirements 13
3.4 Layout of the project 14
3.4.1 Netbeans Part
3.4.2 Database Connectivity
Chapter 4: Modules 16
4.1 Compression Module 17
4.2 Decompression Module 21
vii
Chapter 5: Results and Snapshots 22
5.1 Classes 23
5.2 Functions 28
Chapter 6: Conclusion and Future Scope 31
6.1 Conclusion 32
6.2 Future Scope 32
References 33
viii
LIST OF Tables
Table Title Page No.
3.1 User Account 15
3.2 Image Database 15
ix
LIST OF FIGURES
Figure Title Page No.
1.1 DCT algorithm 6
1.2 Huffman encoding technique 6
1.3 (a) Original Image
(b) Compressed Image
7
3.1 Data Flow Diagram 12
4.1 Original Image 19
4.2 Compressed Image- Quality Factor: 0.5 19
4.3 Compressed Image- Quality Factor: 0.15 20
4.4 Compressed Image- Quality Factor: 0.05 20
4.5 Compressed Image 21
4.6 Decompressed Image 21
5.1.1 Database Connectivity 23
5.1.2 Login Page 24
5.1.3 SignUp Page 24
5.1.4 User Account Page 25
5.1.5 Change Password Page 25
5.1.6 Compression Page 26
5.1.7 jTable 26
5.1.8 My Image Page 27
5.1.9 jFileChooser 27
5.1.10 Decompression 28
5.2.1 ImageWriter Syntax 28
5.2.2 Image Upload Syntax 29
5.2.3 Image Download Syntax 29
5.2.4 Image Download Output 30
Chapter 1
Introduction
2
INTRODUCTION
1.1 Concept :
In recent years, the development and demand of multimedia product grows increasingly fast,
contributing to insufficient bandwidth of network and storage of memory device. Therefore,
the theory of data compression becomes more and more significant for reducing the data
redundancy to save more hardware space and transmission bandwidth. In computer science
and information theory, data compression or source coding is the process of encoding
information using fewer bits or other information-bearing units than an unencoded
representation. Compression is useful because it helps reduce the consumption of expensive
resources such as hard disk space or transmission bandwidth and Decompression is useful
when we take quality of images is taken into consideration. In this project, we briefly
introduce both image compression and image decompression.
1.2 Need of Compression :
Compression means to convert a data of more memory storage to the lesser one. It is useful to
visit or re-visit the reasons why data compression is needed or useful.
One obvious reason is to save the cost of disk. While this may seem strange given that the
disks are cheap. First reason, for the uninitiated, is that the disks used for high-end systems are
not cheap. Secondly, there is rarely a single copy of the production data.
Second reason is the cost of managing the data. Larger the database, it takes longer to do the
backup, recovery.
Third reason is memory. Don’t we all wish we had more memory on our servers? Well, if the
data is compressed, you can fit more data in the same memory. So if you could compress the
data 50%, then suddenly you have increased your memory 100% (i.e. you can fit double the
size of the data). Is this not fantastic? Even if you have 64-bit machine with the capability for
huge amount of addressable memory, the databases, for most customers, is many order of
magnitude larger than the memory. So compression will benefit even for servers running on
64-bit architecture. Clearly your IO bound workloads are likely to see increase in
throughput with data compression as there is less data to be read.
3
1.3 Image Compression :
Image compression is an application of data compression that encodes the original image with
few bits. The objective of image compression is to reduce the redundancy of the image and to
store or transmit data in an efficient form. Image compression is minimizing the size in bytes
of a graphics file without degrading the quality of the image to an unacceptable level. It
involves minimization of the number of information carrying units, pixels. This means that an
image where adjacent pixels have almost the same values leads to spatial redundancy. The
reduction in file size allows more images to be stored in a given amount of disk or memory
space. It also reduces the time required for images to be sent over the Internet or downloaded
from Web pages.
1.3.1 Advantages of Image Compression :
 Less disk space(more data in reality).
 The quantity of bits used to store the data is reduced.
 Faster insertion and deletion .
 Faster file transfer.
 Byte order independent.
 Can zip up several small files into a single file
1.3.2 Disadvantages of Image Compression :
 Added complication.
 Effect of errors in transmission.
 Slower for sophisticated methods.
 Unknown byte/pixel relationship.
 Need to decompress all previousdata.
1.4 Image De-Compression :
The major goal of Image decompression is to image decompression is to decode and
reconstruct the original image. It is an application to get a much better image in terms of
4
quality or size and also we can get original images from their compressed form where we need
that the quality of the image is high whether it may be of higher size.
1.4.1 Advantages of Image De-Compression :
 Quality of the picture is maintained.
 More advantageous where HD pictures are required.
 Need not to decompress further.
 Fine byte/pixel relationship.
1.4.2 Disadvantages of Image Compression :
 Requires more disk space.
 The quantity of bits used to store the data is increased.
 Slower insertion and deletion .
 Slower file transfer.
1.5 Techniques used for Image Compression and De-Compression :
There are several different ways in which image files can be compressed. For Internet use, the
two most common compressed graphic image formats are the JPEG format and the GIF
format. The JPEG method is more often used for photographs, while the GIF method is
commonly used for line art and other images in which geometric shapes are relatively simple.
Other techniques for image compression include the use of fractals and wavelets. These
methods have not gained widespread acceptance for use on the Internet as of this writing.
However, both methods offer promise because they offer higher compression ratios than the
JPEG or GIF methods for some types of images. Another new method that may in time
replace the GIF format is the PNG format.
It is very important to understand that there are two basic types of compression: lossless and
lossy. As the names imply, with lossless compression we will be able to reduce the number of
bytes required to represent the image without losing any information or contents; and with
lossy compression some information will be lost (discarded) in the compression.
5
A text file or program can be compressed without the introduction of errors, but only up to a
certain extent. This is called lossless compression. Beyond this point, errors are introduced. In
text and program files, it is crucial that compression be lossless because a single error can seriously
damage the meaning of a text file, or cause a program not to run. In image compression, a small loss in
quality is usually not noticeable. There is no "critical point" up to which compression works perfectly,
but beyond which it becomes impossible. When there is some tolerance for loss, the compression
factor can be greater than it can when there is no loss tolerance. For this reason, graphic images can be
compressed more than text files or programs.
One may ask why use lossy compression if computers are fast and smart and can deal with
complex algorithms for perfect compression and decompression. Since we are dealing with
images, in most cases losing some information will not compromise the visual quality of the
image and may yield much smaller file sizes. Partly this is because the human visual system is
not as accurate as we would like, and at the same time can easily deal with small details, often
ignoring them (can you really distinguish between the different 16777216 colors that can be
represented in the RGB digital color space?). In images we can expect some regions to have
almost the same color, and we've seen that repetition can lead to good compression.
Image processing algorithms basically use the redundant or almost-redundant information on
images to greatly reduce the number of bytes required to represent them. If a lossless format or
compression method is used, the algorithm will preserve the contents so it can be reproduced
exactly as the original, at the expense of a larger number of bytes to represent it. If a lossy
compression method is used, the algorithm will represent the image with fewer bytes but the
decompressed image will be slightly different from the original -- and for most applications
that will not matter. Exceptions are, of course, applications where the image must be stored
with the original content for further manipulation -- classification comes to mind.
Lossy compression algorithms often allow the user to set a value for the compression level for
the image, allowing the balance between quality and size. Few lossless algorithms allows this,
but often the trade is between better compression and faster processing -- better compression
requiring more processing time.
6
 DCT algorithm.
Fig 1.1 DCT algorithm
 Huffman encoding and decoding technique.
Fig 1.2 Huffman encoding technique
7
 Image Compression using Java:
Using predefined ImageWriter class in java.
 Here we use predefined class ImageWriteParam.
 setCompressionmode() function is used.
Fig 1.3 (a) Original Image Fig 1.3 (b) Compressed Image
8
Chapter 2
Literature Survey
9
LITERATURE SURVEY
Data compression has only played a significant role in computing since the 1970s, when the
Internet was becoming more popular and the Lempel-Ziv algorithms were invented, but it has
a much longer history outside of computing. Morse code, invented in 1838, is the earliest
instance of data compression in that the most common letters in the English language such as
“e” and “t” are given shorter Morse codes. Later, as mainframe computers were starting to
take hold in 1949, Claude Shannon and Robert Fano invented Shannon-Fano coding. Their
algorithm assigns codes to symbols in a given block of data based on the probability of the
symbol occuring. The probability is of a symbol occuring is inversely proportional to the
length of the code, resulting in a shorter way to represent the data. Then many years passed
and images are also going to be used in most of the applications and there is a need to
compress those images so as to make the applications light. Many algorithms were designed
and implemented for the same like DCT algorithm, Huffman encoding technique used to
compress images. Our project is also doing the same. What we have taken into consideration
is to compress the image in terms of size by specifying the quality( high/normal/low). The
results we obtained after compressing are not that much poor but are quite similar to the
original image. Sometimes we need to send the file completely without any problem in that
case we can reduce the quality of the file. Reducing quality of images makes file transfer
process very easy and fast as they are of much bigger size. Today in this present time we are
not available with a lot of time/we want quick responses from every application and we have
tried to reduce application response time by compressing images in this project.
Image Compression is achieved by removing the redundancy in the image. Redundancies in
the image can be classified into three categories; inter-pixel or spatial redundancy, psycho-
visual redundancy and coding redundancy. Inter-pixel Redundancy: Natural images have high
degree of correlation among its pixels. This correlation is referred as inter-pixel redundancy or
spatial redundancy and is removed by either predictive coding or transform coding. Psycho-
visual redundancy: Images are normally meant for consumption of human eyes, which does
not respond with equal sensitivity to all visual information. The relative relevancy of various
10
image information components can be exploited to eliminate or reduce any amount of data that
is psycho-visually redundant. The process, which removes or reduces Psycho-visual
redundancy, is referred as quantization. Coding redundancy: variable-length codes matching to
the statistical model of the image or its processed version exploits the coding redundancy in
the image. Integral University, April 2014 PhD Thesis: Effective Image Compression for
Wireless Sensor Networks Naimur Rahman Kidwai 13 Lossy compression: An Image may be
lossy compressed by removing information, which are not redundant but irrelevant (psycho
visual redundancy). Lossy-compression introduces certain amount of distortion during
compression, resulting in more compression efficiency.
Anil Kumar et al. in their paper two image compression techniques namely, DCT and DWT
are simulated. They concluded that DWT technique is much efficient than DCT in quality and
efficiency wise but in performance time wise DCT is better than DWT. Swastik Das et al.
presented DWT and DCT transformations with their working. They concluded that image
compression is of prime importance in Real time applications like video conferencing where
data are transmitted through a channel. Using JPEG standard, DCT is used for mapping which
reduces the inter pixel redundancies followed by quantization which reduces the psycho visual
redundancies then coding redundancy is reduced by the use of optimal code word having
minimum average length. In JPEG 2000 standard of image compression DWT is used for
mapping, all other methods remaining same. They analysed that DWT is more general and
efficient than DCT.
11
Chapter 3
Methodolgy
12
METHODOLOGY
3.1 Data Flow Diagram :
Fig 3.1 Data Flow Diagram
13
3.2 Class Hierarchy :
o java.lang.Object
o java.awt.Component (implements java.awt.image.ImageObserver,
java.awt.MenuContainer, java.io.Serializable)
o java.awt.Container
o java.awt.Window (implements javax.accessibility.Accessible)
o java.awt.Frame (implements java.awt.MenuContainer)
o javax.swing.JFrame (implements
javax.accessibility.Accessible,
javax.swing.RootPaneContainer,
javax.swing.WindowConstants)
o image.compression.ChangePassword
o image.compression.Decompression
(implements
java.awt.event.ActionListener)
o image.compression.fetchuser
o image.compression.Imageupload
o image.compression.Login
o image.compression.MyAccount
o image.compression.MyImages
o image.compression.NewPass
o image.compression.SecurityQ
o image.compression.signup
o image.compression.Welcome
 image.compression.myconnection
3.3 Software & Hardware Requirements :
 Software requirements :
 operating system :Windows 7/ Windows 8/ Windows 10
 Languages : Java
 Tools : Net Beans, Xampp
 Hardware requirements :
 Processor : 600 MHz or above.
 RAM (SD/DDR) : 256 MB
 Hard Disc : 30GB
14
3.4 Layout of the project :
3.4.1 Netbeans part:
First we have a frame through which we can sign up or login. In the frame we will take
username and password as inputs from user and then on clicking the login button the
application checks whether that username or password exists in the database or not. If
the username and password exists then the application will redirect the user to the
account page else it will display a message saying wrong username and password. On
the same frame we also have a button for signup through which user can create his/her
account if he/she not registered yet and we have also implemented the show password
and forgot password functionalities on the same frame. In the main page we have two
buttons named Compression and Decompression and the application will redirect the
user to the respective pages on clicking them. In Compression module we will load the
image on clicking the browse button and then upload the image in its original and
compressed form both in the database on clicking the upload button. On the same page
itself we have another button named myimages that will show all the images in the
form of tiles that user has uploaded in the database and then we can click on the image
to download it in its compressed. In Decompression module we have a dropdown list
listing the names of all the images that user has uploaded in the database and then we
can click on the button named Decompression to get the decompressed image. This is
all about this desktop application.
3.4.2 Database Connectivity:
Java Database Connectivity (JDBC) is an application programming interface (API) for
the programming language Java, which defines how a client may access a database. It
is part of the Java Standard Edition platform, from Oracle Corporation. It provides
methods to query and update data in a database, and is oriented towards relational
databases.
JDBC allows multiple implementations to exist and be used by the same application.
The API provides a mechanism for dynamically loading the correct Java packages and
15
registering them with the JDBC Driver Manager. The Driver Manager is used as a
connection factory for creating JDBC connections.
JDBC connections support creating and executing statements. These may be update
statements such as SQL's CREATE, INSERT, UPDATE and DELETE, or they may be
query statements such as SELECT.
Query statements return a JDBC row result set. The row result set is used to walk over
the result set. Individual columns in a row are retrieved either by name or by column
number. There may be any number of rows in the result set. The row result set has
metadata that describes the names of the columns and their types.
There is an extension to the basic JDBC API in the javax.sql. If a database operation
fails, JDBC raises an SQLException.
We have two tables under the database image compression:
1. Account(Id, Username, Password, SecurityQ, SecurityA)
2. Tbimages(Id, Username, Title, Original Compressed)
 Account
Field Type Null Default Extra
ID Int(11) No None Auto_Increment
Username Varchar(20) No None
Password Varchar(20) No None
SecurityQ Varchar(50) No None
SecurityA Varchar(50) No None
Table 3.1 User Account
 Tbimages
Field Type Null Default Extra
ID Int(11) No None Auto_Increment
Username Varchar(20) No None
Title Varchar(100) No None
Original Longblob No None
Compressed Longblob No None
Table 3.2 Image Database
16
Chapter 4
Modules
17
MODULES
4.1 Compression Module :
Compression of image file is one of the important task when it comes to save the large number
of image files. It saves lot of space if you could compress the images when it is necessary. An
image can easily be compressed and stored through Java. Compression of image involves
converting an image into jpg and storing it. In order to compress an image, we read the image
and convert into BufferedImage object. Further, we get an ImageWriter from
getImageWritersByFormatName() method found in the ImageIO class. From this
ImageWriter, create an ImageWriteParam object. ImageWriteParam class is mainly used for
compression the images. Its syntax is given below:
Iterator<ImageWriter> list = ImageIO.getImageWritersByFormatName("jpg");
ImageWriteParam obj = writer_From_List.getDefaultWriteParam();
It has two methods which is mostly used for changing the compression settings:
setCompressionQuality() method used for setting the quality of the compressed image the
value between 0 to 1. A compression quality setting of 0.0 is most generically interpreted as
“high compression is important,” while a setting of 1.0 is most generically interpreted as “high
image quality is important.” Also we used method setCompressionMode() to set the mode of
the compression. The setCompressionMode() method takes Mode_EXPLICIT as the
parameter.
Some of the other modes are described briefly:
 MODE_DEFAULT
It is a constant value that may be passed into methods to enable that feature for future
writes.
 MODE_DISABLED
It is a constant value that may be passed into methods to disable that feature for future
writes.
18
 MODE_EXPLICIT
It is a constant value that may be passed into methods to enable that feature for future
writes.
Apart from the compressions methods, there are other methods provided by the
ImageWriteParam class. They are described briefly:
 canOffsetTiles()
It returns true if the writer can perform tiling with non-zero grid offsets while writing.
 getBitRate(float quality)
It returns a float indicating an estimate of the number of bits of output data for each bit
of input image data at the given quality level.
 getLocale()
It returns the currently set Locale, or null if only a default Locale is supported.
 isCompressionLossless()
It returns true if the current compression type provides lossless compression.
 unsetCompression()
It removes any previous compression type and quality settings.
 unsetTiling()
It removes any previous tile grid parameters specified by calls to setTiling.
Output:
When you execute the code, it compresses the image to its equivalent compressed image
according to the choosen quality factor and writes it on the hard disk with the
name compress.jpg.
19
Original Image:
Fig 4.1 Original Image
Compressed Image- Quality Factor: 0.5
Fig 4.2 Compressed Image- Quality Factor: 0.5
20
Compressed Image- Quality Factor: 0.15
Fig 4.3 Compressed Image- Quality Factor: 0.15
Compressed Image- Quality Factor: 0.5
Fig 4.4 Compressed Image- Quality Factor: 0.05
21
4.2 Decompression Module :
It is an application to get a much better image in terms of quality or size and also we can get
original images from their compressed form where we need that the quality of the image is
high whether it may be of higher size.
Output:
Compressed Image:
Fig 4.5 Compressed Image
Decompressed Image:
Fig 4.6 Decompressed Image
22
Chapter 5
Results and Snapshots
23
RESULTS AND SNAPSHOTS
5.1 Classes :
 MyConnection
This class is being used for database connectivity. It is building a connection between
database server and java project.
Fig 5.1.1 Database Connectivity
 Login
It is jframe which acts as the login page of the project. It provides access to the project
to the registered users by identifying and authenticating themselves. This frame links
to three different frames:
 MyAccount
 ForgotPassword: In case users forgots his/her password he/she can change the
password by entering username and answering the security question set while
signing up
 SignUp: For new users to register themselves and create their account.
24
Fig 5.1.2 Login Page
Fig 5.1.3 SignUp Page
25
 MyAccount
This frame refers to the user account page and it contains to buttons that links to two
different modules: compression and decompression. User can choose any of the
functionality according to the need. Clicking on “compression” button will redirect the
user to compression page where user can upload images and compress it choosing
some quality according to the requirement. Clicking on “decompression” button will
redirect the user to decompression page where user can select uploaded and
compressed images to decompress and save it on the system. It also contains a button
with an option of change user password where user can change his/her password.
Fig 5.1.4 User Account Page Fig 5.1.5 Change Password Page
 Compression
This frame contains the functionality of compression module. In this frame user
browse for the image on system and upload the image on the database. Before
uploading user needs to choose the quality of image after compression. Size of image
after compression depends on the quality choosen, i.e, choosing high quality will result
in compressed image bigger in size than that with normal or low quality. As soon as
the user clicks on the upload button compression process takes place and the original
image and compressed image gets stored in the database.
26
Fig 5.1.6 Compression Page
 MyImages
Using this frame user can choose uploaded and compressed images and can save it on
his/her system by selecting the image and clicking on download button on joptionpane.
Compressed images stored in the database are displayed on this frame in in form of
tiles with the help of jtable and its functions.
Fig 5.1.7 jTable
27
Fig 5.1.8 My Images Page
 Decompression
This frame consists of decompression part. In this frame user is allowed to choose
image from the the list of previously uploaded images. When user clicks on
“decompress” button he/she needs to choose the path where he/she wants to store the
decompressed image on the system and the extention in which he wants to write the
image.Choosing the correct extenstion is important as it decides the quality of image.
Fig 5.1.9 jFileChooser Syntax
28
Fig 5.1.10 Decompression Page
5.2 Functions :
 Compression and Decompression
In order to compress an image, we read the image and convert into BufferedImage
object. Further, we get an ImageWriter from getImageWritersByFormatName()
method found in the ImageIO class. From this ImageWriter, create an
ImageWriteParam object.
Fig 5.2.1 ImageWriter Syntax
29
 Upload Image
We convert a BufferedImage to byte array in order to send it to server. We use Java
class ByteArrayOutputStream, which can be found underjava.io package. Its syntax is
given below:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, "jpg", baos);
In order to convert the image to byte array, we use toByteArray() method of
ByteArrayOutputStream class. Its syntax is given below:
byte[] bytes = baos.toByteArray();
Fig 5.2.2 Image Upload Syntax
 Download Image
To get the image from the databse and download it on system follwing functins are
executed:
Fig 5.2.3 Image Download Syntax
30
When you execute the code given above, output something like this seen:
Fig 5.2.3 Image Download Output
31
Chapter 6
Conclusion and Future
Scope
32
CONCLUSION AND FUTURE SCOPE
6.1 Conclusion
Data compression is very important in the computing world and it is commonly used by many
applications, including the suite of SyncBack programs. In providing a brief overview on how
compression works in general it is hoped this project allows users of data compression to
weigh the advantages and disadvantages.
6.2 Future Scope
In this project, many of the current important image compression and encryption techniques
have been presented and analyzed. The best way of fast and secure transmission is by using
compression and encryption of multimedia data like images. The compression technique
observed is either lossy or lossless. Always lossless compression is preferred but to achieve
secrecy some image quality degradation is accepted. Encryption applied by different
researchers by means of encrypting algorithm which encrypt the entire or partial multimedia
bit sequence using a fast conventional cryptosystem. Much of the past and current research
targets encrypting only a carefully selected part of the image bitstream in order to reduce the
computational load, and yet keep the security level high. In the proposed approach the key is
required to send separately. This is a different issue of securely transmitting the secret key.
Future scope of the proposed work is that we can design the mechanism to securely transmit
the key so that unauthorized person should have no access to it.
33
References
 http://www.javabeat.net/java-compress-image/
 http://www.tutorialspoint.com/java_dip/image_compression_technique.htm
 http://www.lac.inpe.br/JIPCookbook/6040-howto-compressimages.jsp
 http://www.javatpoint.com/steps-to-connect-to-the-database-in-java
 http://www.tutorialspoint.com/jdbc/jdbc-db-connections.htm

More Related Content

PDF
Digital watermarking on medical images using dwt
PPT
Multimedia image compression standards
DOC
Seminar Report on image compression
DOCX
Thesis on Image compression by Manish Myst
PPTX
Digital watermarking
PPT
Compression techniques
PPTX
Data compression
PPTX
Multimedia_image recognition steps
Digital watermarking on medical images using dwt
Multimedia image compression standards
Seminar Report on image compression
Thesis on Image compression by Manish Myst
Digital watermarking
Compression techniques
Data compression
Multimedia_image recognition steps

What's hot (20)

PPTX
Brain tumor detection using convolutional neural network
PPTX
Fundamentals of Data compression
PDF
Lecture 4 Relationship between pixels
PPTX
Image Steganography using LSB
PPTX
Image compression: Techniques and Application
PPTX
Audio compression
PDF
Chapter 3 - Multimedia System Design
PDF
Chapter 5 - Data Compression
PPTX
Multimedia synchronization
PPT
Fields of digital image processing slides
PPTX
Chapter 9 morphological image processing
PPTX
Image Compression Using Neural Network
PPT
Data Redundacy
PPTX
Image compression models
PPTX
Chapter 9 morphological image processing
PPTX
Comparison between JPEG(DCT) and JPEG 2000(DWT) compression standards
PPTX
Data Compression (Lossy and Lossless)
PPT
Data compression
PPTX
Digital Watermarking Of Medical(DICOM) Images
PPTX
Object detection
Brain tumor detection using convolutional neural network
Fundamentals of Data compression
Lecture 4 Relationship between pixels
Image Steganography using LSB
Image compression: Techniques and Application
Audio compression
Chapter 3 - Multimedia System Design
Chapter 5 - Data Compression
Multimedia synchronization
Fields of digital image processing slides
Chapter 9 morphological image processing
Image Compression Using Neural Network
Data Redundacy
Image compression models
Chapter 9 morphological image processing
Comparison between JPEG(DCT) and JPEG 2000(DWT) compression standards
Data Compression (Lossy and Lossless)
Data compression
Digital Watermarking Of Medical(DICOM) Images
Object detection
Ad

Similar to IMAGE COMPRESSION AND DECOMPRESSION SYSTEM (20)

PDF
Enhanced Image Compression Using Wavelets
PDF
IRJET- Image Compressor
PDF
IRJET- Image Compressor
PDF
[IJCT-V3I2P27] Authors: Palwinder Singh
PDF
Cuda Based Performance Evaluation Of The Computational Efficiency Of The Dct ...
PDF
DISCRETE COSINE TRANSFORM WITH ADAPTIVE HUFFMAN CODING BASED IMAGE COMPRESSION
PDF
Efficient Image Compression Technique using Clustering and Random Permutation
PDF
Efficient Image Compression Technique using Clustering and Random Permutation
PDF
M.sc.iii sem digital image processing unit v
PDF
Mobile Device Oriented Image Scaling for Reducing Memory Consumption in stor...
PDF
An Enhanced trusted Image Storing and Retrieval Framework in Cloud Data Stora...
PDF
A LITERATURE SURVEY ON SECURE JOINT DATA HIDING AND COMPRESSION SCHEME TO STO...
PDF
Effective Compression of Digital Video
PDF
Implementation of Fractal Image Compression on Medical Images by Different Ap...
PDF
Novel hybrid framework for image compression for supportive hardware design o...
PDF
Reduction of Blocking Artifacts In JPEG Compressed Image
PDF
Evaluation Of Proposed Design And Necessary Corrective Action
PDF
Lossless Image Compression Techniques Comparative Study
PDF
A Step Towards A Scalable Dynamic Single Assignment Conversion
PDF
Enhancing readability of digital image using image processing - Full Report
Enhanced Image Compression Using Wavelets
IRJET- Image Compressor
IRJET- Image Compressor
[IJCT-V3I2P27] Authors: Palwinder Singh
Cuda Based Performance Evaluation Of The Computational Efficiency Of The Dct ...
DISCRETE COSINE TRANSFORM WITH ADAPTIVE HUFFMAN CODING BASED IMAGE COMPRESSION
Efficient Image Compression Technique using Clustering and Random Permutation
Efficient Image Compression Technique using Clustering and Random Permutation
M.sc.iii sem digital image processing unit v
Mobile Device Oriented Image Scaling for Reducing Memory Consumption in stor...
An Enhanced trusted Image Storing and Retrieval Framework in Cloud Data Stora...
A LITERATURE SURVEY ON SECURE JOINT DATA HIDING AND COMPRESSION SCHEME TO STO...
Effective Compression of Digital Video
Implementation of Fractal Image Compression on Medical Images by Different Ap...
Novel hybrid framework for image compression for supportive hardware design o...
Reduction of Blocking Artifacts In JPEG Compressed Image
Evaluation Of Proposed Design And Necessary Corrective Action
Lossless Image Compression Techniques Comparative Study
A Step Towards A Scalable Dynamic Single Assignment Conversion
Enhancing readability of digital image using image processing - Full Report
Ad

Recently uploaded (20)

PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PPTX
Geodesy 1.pptx...............................................
PPTX
Sustainable Sites - Green Building Construction
PPTX
Artificial Intelligence
PDF
Categorization of Factors Affecting Classification Algorithms Selection
PDF
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
Internet of Things (IOT) - A guide to understanding
PPT
Mechanical Engineering MATERIALS Selection
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
Embodied AI: Ushering in the Next Era of Intelligent Systems
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Automation-in-Manufacturing-Chapter-Introduction.pdf
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
Geodesy 1.pptx...............................................
Sustainable Sites - Green Building Construction
Artificial Intelligence
Categorization of Factors Affecting Classification Algorithms Selection
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Internet of Things (IOT) - A guide to understanding
Mechanical Engineering MATERIALS Selection
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION

IMAGE COMPRESSION AND DECOMPRESSION SYSTEM

  • 1. INTEGRATED PROJECT REPORT On IMAGE COMPRESSION AND DECOMPRESSION SYSTEM Submitted in partial fulfillment of the requirement for the Course Integrated Project-II (CSP2204) of COMPUTER SCIENCE AND ENGINEERING Batch-2014 in May-2016 Under the Guidance of: Submitted By: Ms. Ankita Tuteja Vishesh 1411981272 Shubham Kansal 1411981225 Vipin Kumar 1411981265 Vikrant Chaudhary 1411981261 DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING CHITKARA UNIVERSITY HIMACHAL PRADESH
  • 2. ii CERTIFICATE This is to be certified that the project entitled “Image Compression and Decompression System” has been submitted for the Bachelor of Computer Science Engineering at Chitkara University, Himachal Pradesh during the academic semester January 2016- May 2016 is bonafide piece of project work carried out by Vishesh (1411981272), Shubham Kansal (1411981225), Vipin Kumar (1411981265) and Vikrant Chaudhary (1411981261) towards the partial fulfillment for the award of course Integrated Project (CSP-2204) under the guidance of Ms. Ankita Tuteja and supervision. Signature of Project Guide Ms. Ankita Tuteja (Assistant Professor, CSE Department)
  • 3. iii CANDIDATE’S DECLARATION We, Vishesh (1411981272), Shubham Kansal (1411981225), Vipin Kumar (1411981265) and Vikrant Chaudhary (1411981261), B.E.-2014 of the Chitkara University, Himachal Pradesh hereby declare that the Integrated Project Report entitled “Image Compression and Decompression System” is an original work and data provided in the study is authentic to the best of our knowledge. This report has not been submitted to any other Institute for the award of any other course. Sign. of Student 1 Sign. of Student 2 Sign. of Student 3 Sign. of Student 4 Vishesh Shubham Kansal Vipin Kumar Vikrant Chaudhary 1411981272 1411981225 1411981265 1411981261 Place: Date:
  • 4. iv ABSTRACT The compression and decompression of continuous-tone images is important in document management and transmission systems. Image compression is the application of Data compression on digital images. In effect, the objective is to reduce redundancy of the image data in order to be able to store or transmit data in an efficient form. Therefore, the theory of data compression becomes more and more significant for reducing the data redundancy to save more hardware space and transmission bandwidth. In computer science and information theory, data compression or source coding is the process of encoding information using fewer bits or other information-bearing units than an unencoded representation. Compression is useful because it helps reduce the consumption of expensive resources such as hard disk space or transmission bandwidth and Decompression is useful when we take quality of images is taken into consideration. In this project, we briefly introduce both image compression and image decompression.
  • 5. v ACKNOWLEDGEMENT It is our pleasure to be indebted to various people, who directly or indirectly contributed in the development of this work and who influenced our thinking, behavior and acts during the course of study. We express our sincere gratitude to all for providing an opportunity to undergo Integrated Project-II as the part of the curriculum. We are thankful to “Ms. Ankita Tuteja” for her support, cooperation, and motivation provided to us during the training for constant inspiration, presence and blessings. Lastly, We would like to thank the almighty and our parents for their moral support and friends with whom we shared our day-to day experience and received lots of suggestions that improve our quality of work. With Sincere Thanks, Vishesh (1411981272), Shubham (1411981225), Vipin (1411981265), Vikrant (1411981261)
  • 6. vi TABLE OF CONTENTS Page No. Abstract iv Acknowledgement v List of Tables viii List of Figures ix Chapter 1: Introduction 1 1.1 Concept 2 1.2 Need of Compression 2 1.3 Image Compression 3 1.3.1 Advantages of Image Compression 1.3.2 Disadvantages of Image Compression 1.4 Image Decompression 3 1.4.1 Advantages of Image Decompression 1.4.2 Disadvantages of Image Decompression 1.5 Techniques used for Image Compression and De-Compression 4 Chapter 2: Literature Survey 8 Chapter 3: Methodology 10 3.1 Data Flow Diagram 12 3.2 Class Hierarchy 13 3.3 Software and Hardware Requirements 13 3.4 Layout of the project 14 3.4.1 Netbeans Part 3.4.2 Database Connectivity Chapter 4: Modules 16 4.1 Compression Module 17 4.2 Decompression Module 21
  • 7. vii Chapter 5: Results and Snapshots 22 5.1 Classes 23 5.2 Functions 28 Chapter 6: Conclusion and Future Scope 31 6.1 Conclusion 32 6.2 Future Scope 32 References 33
  • 8. viii LIST OF Tables Table Title Page No. 3.1 User Account 15 3.2 Image Database 15
  • 9. ix LIST OF FIGURES Figure Title Page No. 1.1 DCT algorithm 6 1.2 Huffman encoding technique 6 1.3 (a) Original Image (b) Compressed Image 7 3.1 Data Flow Diagram 12 4.1 Original Image 19 4.2 Compressed Image- Quality Factor: 0.5 19 4.3 Compressed Image- Quality Factor: 0.15 20 4.4 Compressed Image- Quality Factor: 0.05 20 4.5 Compressed Image 21 4.6 Decompressed Image 21 5.1.1 Database Connectivity 23 5.1.2 Login Page 24 5.1.3 SignUp Page 24 5.1.4 User Account Page 25 5.1.5 Change Password Page 25 5.1.6 Compression Page 26 5.1.7 jTable 26 5.1.8 My Image Page 27 5.1.9 jFileChooser 27 5.1.10 Decompression 28 5.2.1 ImageWriter Syntax 28 5.2.2 Image Upload Syntax 29 5.2.3 Image Download Syntax 29 5.2.4 Image Download Output 30
  • 11. 2 INTRODUCTION 1.1 Concept : In recent years, the development and demand of multimedia product grows increasingly fast, contributing to insufficient bandwidth of network and storage of memory device. Therefore, the theory of data compression becomes more and more significant for reducing the data redundancy to save more hardware space and transmission bandwidth. In computer science and information theory, data compression or source coding is the process of encoding information using fewer bits or other information-bearing units than an unencoded representation. Compression is useful because it helps reduce the consumption of expensive resources such as hard disk space or transmission bandwidth and Decompression is useful when we take quality of images is taken into consideration. In this project, we briefly introduce both image compression and image decompression. 1.2 Need of Compression : Compression means to convert a data of more memory storage to the lesser one. It is useful to visit or re-visit the reasons why data compression is needed or useful. One obvious reason is to save the cost of disk. While this may seem strange given that the disks are cheap. First reason, for the uninitiated, is that the disks used for high-end systems are not cheap. Secondly, there is rarely a single copy of the production data. Second reason is the cost of managing the data. Larger the database, it takes longer to do the backup, recovery. Third reason is memory. Don’t we all wish we had more memory on our servers? Well, if the data is compressed, you can fit more data in the same memory. So if you could compress the data 50%, then suddenly you have increased your memory 100% (i.e. you can fit double the size of the data). Is this not fantastic? Even if you have 64-bit machine with the capability for huge amount of addressable memory, the databases, for most customers, is many order of magnitude larger than the memory. So compression will benefit even for servers running on 64-bit architecture. Clearly your IO bound workloads are likely to see increase in throughput with data compression as there is less data to be read.
  • 12. 3 1.3 Image Compression : Image compression is an application of data compression that encodes the original image with few bits. The objective of image compression is to reduce the redundancy of the image and to store or transmit data in an efficient form. Image compression is minimizing the size in bytes of a graphics file without degrading the quality of the image to an unacceptable level. It involves minimization of the number of information carrying units, pixels. This means that an image where adjacent pixels have almost the same values leads to spatial redundancy. The reduction in file size allows more images to be stored in a given amount of disk or memory space. It also reduces the time required for images to be sent over the Internet or downloaded from Web pages. 1.3.1 Advantages of Image Compression :  Less disk space(more data in reality).  The quantity of bits used to store the data is reduced.  Faster insertion and deletion .  Faster file transfer.  Byte order independent.  Can zip up several small files into a single file 1.3.2 Disadvantages of Image Compression :  Added complication.  Effect of errors in transmission.  Slower for sophisticated methods.  Unknown byte/pixel relationship.  Need to decompress all previousdata. 1.4 Image De-Compression : The major goal of Image decompression is to image decompression is to decode and reconstruct the original image. It is an application to get a much better image in terms of
  • 13. 4 quality or size and also we can get original images from their compressed form where we need that the quality of the image is high whether it may be of higher size. 1.4.1 Advantages of Image De-Compression :  Quality of the picture is maintained.  More advantageous where HD pictures are required.  Need not to decompress further.  Fine byte/pixel relationship. 1.4.2 Disadvantages of Image Compression :  Requires more disk space.  The quantity of bits used to store the data is increased.  Slower insertion and deletion .  Slower file transfer. 1.5 Techniques used for Image Compression and De-Compression : There are several different ways in which image files can be compressed. For Internet use, the two most common compressed graphic image formats are the JPEG format and the GIF format. The JPEG method is more often used for photographs, while the GIF method is commonly used for line art and other images in which geometric shapes are relatively simple. Other techniques for image compression include the use of fractals and wavelets. These methods have not gained widespread acceptance for use on the Internet as of this writing. However, both methods offer promise because they offer higher compression ratios than the JPEG or GIF methods for some types of images. Another new method that may in time replace the GIF format is the PNG format. It is very important to understand that there are two basic types of compression: lossless and lossy. As the names imply, with lossless compression we will be able to reduce the number of bytes required to represent the image without losing any information or contents; and with lossy compression some information will be lost (discarded) in the compression.
  • 14. 5 A text file or program can be compressed without the introduction of errors, but only up to a certain extent. This is called lossless compression. Beyond this point, errors are introduced. In text and program files, it is crucial that compression be lossless because a single error can seriously damage the meaning of a text file, or cause a program not to run. In image compression, a small loss in quality is usually not noticeable. There is no "critical point" up to which compression works perfectly, but beyond which it becomes impossible. When there is some tolerance for loss, the compression factor can be greater than it can when there is no loss tolerance. For this reason, graphic images can be compressed more than text files or programs. One may ask why use lossy compression if computers are fast and smart and can deal with complex algorithms for perfect compression and decompression. Since we are dealing with images, in most cases losing some information will not compromise the visual quality of the image and may yield much smaller file sizes. Partly this is because the human visual system is not as accurate as we would like, and at the same time can easily deal with small details, often ignoring them (can you really distinguish between the different 16777216 colors that can be represented in the RGB digital color space?). In images we can expect some regions to have almost the same color, and we've seen that repetition can lead to good compression. Image processing algorithms basically use the redundant or almost-redundant information on images to greatly reduce the number of bytes required to represent them. If a lossless format or compression method is used, the algorithm will preserve the contents so it can be reproduced exactly as the original, at the expense of a larger number of bytes to represent it. If a lossy compression method is used, the algorithm will represent the image with fewer bytes but the decompressed image will be slightly different from the original -- and for most applications that will not matter. Exceptions are, of course, applications where the image must be stored with the original content for further manipulation -- classification comes to mind. Lossy compression algorithms often allow the user to set a value for the compression level for the image, allowing the balance between quality and size. Few lossless algorithms allows this, but often the trade is between better compression and faster processing -- better compression requiring more processing time.
  • 15. 6  DCT algorithm. Fig 1.1 DCT algorithm  Huffman encoding and decoding technique. Fig 1.2 Huffman encoding technique
  • 16. 7  Image Compression using Java: Using predefined ImageWriter class in java.  Here we use predefined class ImageWriteParam.  setCompressionmode() function is used. Fig 1.3 (a) Original Image Fig 1.3 (b) Compressed Image
  • 18. 9 LITERATURE SURVEY Data compression has only played a significant role in computing since the 1970s, when the Internet was becoming more popular and the Lempel-Ziv algorithms were invented, but it has a much longer history outside of computing. Morse code, invented in 1838, is the earliest instance of data compression in that the most common letters in the English language such as “e” and “t” are given shorter Morse codes. Later, as mainframe computers were starting to take hold in 1949, Claude Shannon and Robert Fano invented Shannon-Fano coding. Their algorithm assigns codes to symbols in a given block of data based on the probability of the symbol occuring. The probability is of a symbol occuring is inversely proportional to the length of the code, resulting in a shorter way to represent the data. Then many years passed and images are also going to be used in most of the applications and there is a need to compress those images so as to make the applications light. Many algorithms were designed and implemented for the same like DCT algorithm, Huffman encoding technique used to compress images. Our project is also doing the same. What we have taken into consideration is to compress the image in terms of size by specifying the quality( high/normal/low). The results we obtained after compressing are not that much poor but are quite similar to the original image. Sometimes we need to send the file completely without any problem in that case we can reduce the quality of the file. Reducing quality of images makes file transfer process very easy and fast as they are of much bigger size. Today in this present time we are not available with a lot of time/we want quick responses from every application and we have tried to reduce application response time by compressing images in this project. Image Compression is achieved by removing the redundancy in the image. Redundancies in the image can be classified into three categories; inter-pixel or spatial redundancy, psycho- visual redundancy and coding redundancy. Inter-pixel Redundancy: Natural images have high degree of correlation among its pixels. This correlation is referred as inter-pixel redundancy or spatial redundancy and is removed by either predictive coding or transform coding. Psycho- visual redundancy: Images are normally meant for consumption of human eyes, which does not respond with equal sensitivity to all visual information. The relative relevancy of various
  • 19. 10 image information components can be exploited to eliminate or reduce any amount of data that is psycho-visually redundant. The process, which removes or reduces Psycho-visual redundancy, is referred as quantization. Coding redundancy: variable-length codes matching to the statistical model of the image or its processed version exploits the coding redundancy in the image. Integral University, April 2014 PhD Thesis: Effective Image Compression for Wireless Sensor Networks Naimur Rahman Kidwai 13 Lossy compression: An Image may be lossy compressed by removing information, which are not redundant but irrelevant (psycho visual redundancy). Lossy-compression introduces certain amount of distortion during compression, resulting in more compression efficiency. Anil Kumar et al. in their paper two image compression techniques namely, DCT and DWT are simulated. They concluded that DWT technique is much efficient than DCT in quality and efficiency wise but in performance time wise DCT is better than DWT. Swastik Das et al. presented DWT and DCT transformations with their working. They concluded that image compression is of prime importance in Real time applications like video conferencing where data are transmitted through a channel. Using JPEG standard, DCT is used for mapping which reduces the inter pixel redundancies followed by quantization which reduces the psycho visual redundancies then coding redundancy is reduced by the use of optimal code word having minimum average length. In JPEG 2000 standard of image compression DWT is used for mapping, all other methods remaining same. They analysed that DWT is more general and efficient than DCT.
  • 21. 12 METHODOLOGY 3.1 Data Flow Diagram : Fig 3.1 Data Flow Diagram
  • 22. 13 3.2 Class Hierarchy : o java.lang.Object o java.awt.Component (implements java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable) o java.awt.Container o java.awt.Window (implements javax.accessibility.Accessible) o java.awt.Frame (implements java.awt.MenuContainer) o javax.swing.JFrame (implements javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants) o image.compression.ChangePassword o image.compression.Decompression (implements java.awt.event.ActionListener) o image.compression.fetchuser o image.compression.Imageupload o image.compression.Login o image.compression.MyAccount o image.compression.MyImages o image.compression.NewPass o image.compression.SecurityQ o image.compression.signup o image.compression.Welcome  image.compression.myconnection 3.3 Software & Hardware Requirements :  Software requirements :  operating system :Windows 7/ Windows 8/ Windows 10  Languages : Java  Tools : Net Beans, Xampp  Hardware requirements :  Processor : 600 MHz or above.  RAM (SD/DDR) : 256 MB  Hard Disc : 30GB
  • 23. 14 3.4 Layout of the project : 3.4.1 Netbeans part: First we have a frame through which we can sign up or login. In the frame we will take username and password as inputs from user and then on clicking the login button the application checks whether that username or password exists in the database or not. If the username and password exists then the application will redirect the user to the account page else it will display a message saying wrong username and password. On the same frame we also have a button for signup through which user can create his/her account if he/she not registered yet and we have also implemented the show password and forgot password functionalities on the same frame. In the main page we have two buttons named Compression and Decompression and the application will redirect the user to the respective pages on clicking them. In Compression module we will load the image on clicking the browse button and then upload the image in its original and compressed form both in the database on clicking the upload button. On the same page itself we have another button named myimages that will show all the images in the form of tiles that user has uploaded in the database and then we can click on the image to download it in its compressed. In Decompression module we have a dropdown list listing the names of all the images that user has uploaded in the database and then we can click on the button named Decompression to get the decompressed image. This is all about this desktop application. 3.4.2 Database Connectivity: Java Database Connectivity (JDBC) is an application programming interface (API) for the programming language Java, which defines how a client may access a database. It is part of the Java Standard Edition platform, from Oracle Corporation. It provides methods to query and update data in a database, and is oriented towards relational databases. JDBC allows multiple implementations to exist and be used by the same application. The API provides a mechanism for dynamically loading the correct Java packages and
  • 24. 15 registering them with the JDBC Driver Manager. The Driver Manager is used as a connection factory for creating JDBC connections. JDBC connections support creating and executing statements. These may be update statements such as SQL's CREATE, INSERT, UPDATE and DELETE, or they may be query statements such as SELECT. Query statements return a JDBC row result set. The row result set is used to walk over the result set. Individual columns in a row are retrieved either by name or by column number. There may be any number of rows in the result set. The row result set has metadata that describes the names of the columns and their types. There is an extension to the basic JDBC API in the javax.sql. If a database operation fails, JDBC raises an SQLException. We have two tables under the database image compression: 1. Account(Id, Username, Password, SecurityQ, SecurityA) 2. Tbimages(Id, Username, Title, Original Compressed)  Account Field Type Null Default Extra ID Int(11) No None Auto_Increment Username Varchar(20) No None Password Varchar(20) No None SecurityQ Varchar(50) No None SecurityA Varchar(50) No None Table 3.1 User Account  Tbimages Field Type Null Default Extra ID Int(11) No None Auto_Increment Username Varchar(20) No None Title Varchar(100) No None Original Longblob No None Compressed Longblob No None Table 3.2 Image Database
  • 26. 17 MODULES 4.1 Compression Module : Compression of image file is one of the important task when it comes to save the large number of image files. It saves lot of space if you could compress the images when it is necessary. An image can easily be compressed and stored through Java. Compression of image involves converting an image into jpg and storing it. In order to compress an image, we read the image and convert into BufferedImage object. Further, we get an ImageWriter from getImageWritersByFormatName() method found in the ImageIO class. From this ImageWriter, create an ImageWriteParam object. ImageWriteParam class is mainly used for compression the images. Its syntax is given below: Iterator<ImageWriter> list = ImageIO.getImageWritersByFormatName("jpg"); ImageWriteParam obj = writer_From_List.getDefaultWriteParam(); It has two methods which is mostly used for changing the compression settings: setCompressionQuality() method used for setting the quality of the compressed image the value between 0 to 1. A compression quality setting of 0.0 is most generically interpreted as “high compression is important,” while a setting of 1.0 is most generically interpreted as “high image quality is important.” Also we used method setCompressionMode() to set the mode of the compression. The setCompressionMode() method takes Mode_EXPLICIT as the parameter. Some of the other modes are described briefly:  MODE_DEFAULT It is a constant value that may be passed into methods to enable that feature for future writes.  MODE_DISABLED It is a constant value that may be passed into methods to disable that feature for future writes.
  • 27. 18  MODE_EXPLICIT It is a constant value that may be passed into methods to enable that feature for future writes. Apart from the compressions methods, there are other methods provided by the ImageWriteParam class. They are described briefly:  canOffsetTiles() It returns true if the writer can perform tiling with non-zero grid offsets while writing.  getBitRate(float quality) It returns a float indicating an estimate of the number of bits of output data for each bit of input image data at the given quality level.  getLocale() It returns the currently set Locale, or null if only a default Locale is supported.  isCompressionLossless() It returns true if the current compression type provides lossless compression.  unsetCompression() It removes any previous compression type and quality settings.  unsetTiling() It removes any previous tile grid parameters specified by calls to setTiling. Output: When you execute the code, it compresses the image to its equivalent compressed image according to the choosen quality factor and writes it on the hard disk with the name compress.jpg.
  • 28. 19 Original Image: Fig 4.1 Original Image Compressed Image- Quality Factor: 0.5 Fig 4.2 Compressed Image- Quality Factor: 0.5
  • 29. 20 Compressed Image- Quality Factor: 0.15 Fig 4.3 Compressed Image- Quality Factor: 0.15 Compressed Image- Quality Factor: 0.5 Fig 4.4 Compressed Image- Quality Factor: 0.05
  • 30. 21 4.2 Decompression Module : It is an application to get a much better image in terms of quality or size and also we can get original images from their compressed form where we need that the quality of the image is high whether it may be of higher size. Output: Compressed Image: Fig 4.5 Compressed Image Decompressed Image: Fig 4.6 Decompressed Image
  • 32. 23 RESULTS AND SNAPSHOTS 5.1 Classes :  MyConnection This class is being used for database connectivity. It is building a connection between database server and java project. Fig 5.1.1 Database Connectivity  Login It is jframe which acts as the login page of the project. It provides access to the project to the registered users by identifying and authenticating themselves. This frame links to three different frames:  MyAccount  ForgotPassword: In case users forgots his/her password he/she can change the password by entering username and answering the security question set while signing up  SignUp: For new users to register themselves and create their account.
  • 33. 24 Fig 5.1.2 Login Page Fig 5.1.3 SignUp Page
  • 34. 25  MyAccount This frame refers to the user account page and it contains to buttons that links to two different modules: compression and decompression. User can choose any of the functionality according to the need. Clicking on “compression” button will redirect the user to compression page where user can upload images and compress it choosing some quality according to the requirement. Clicking on “decompression” button will redirect the user to decompression page where user can select uploaded and compressed images to decompress and save it on the system. It also contains a button with an option of change user password where user can change his/her password. Fig 5.1.4 User Account Page Fig 5.1.5 Change Password Page  Compression This frame contains the functionality of compression module. In this frame user browse for the image on system and upload the image on the database. Before uploading user needs to choose the quality of image after compression. Size of image after compression depends on the quality choosen, i.e, choosing high quality will result in compressed image bigger in size than that with normal or low quality. As soon as the user clicks on the upload button compression process takes place and the original image and compressed image gets stored in the database.
  • 35. 26 Fig 5.1.6 Compression Page  MyImages Using this frame user can choose uploaded and compressed images and can save it on his/her system by selecting the image and clicking on download button on joptionpane. Compressed images stored in the database are displayed on this frame in in form of tiles with the help of jtable and its functions. Fig 5.1.7 jTable
  • 36. 27 Fig 5.1.8 My Images Page  Decompression This frame consists of decompression part. In this frame user is allowed to choose image from the the list of previously uploaded images. When user clicks on “decompress” button he/she needs to choose the path where he/she wants to store the decompressed image on the system and the extention in which he wants to write the image.Choosing the correct extenstion is important as it decides the quality of image. Fig 5.1.9 jFileChooser Syntax
  • 37. 28 Fig 5.1.10 Decompression Page 5.2 Functions :  Compression and Decompression In order to compress an image, we read the image and convert into BufferedImage object. Further, we get an ImageWriter from getImageWritersByFormatName() method found in the ImageIO class. From this ImageWriter, create an ImageWriteParam object. Fig 5.2.1 ImageWriter Syntax
  • 38. 29  Upload Image We convert a BufferedImage to byte array in order to send it to server. We use Java class ByteArrayOutputStream, which can be found underjava.io package. Its syntax is given below: ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(image, "jpg", baos); In order to convert the image to byte array, we use toByteArray() method of ByteArrayOutputStream class. Its syntax is given below: byte[] bytes = baos.toByteArray(); Fig 5.2.2 Image Upload Syntax  Download Image To get the image from the databse and download it on system follwing functins are executed: Fig 5.2.3 Image Download Syntax
  • 39. 30 When you execute the code given above, output something like this seen: Fig 5.2.3 Image Download Output
  • 41. 32 CONCLUSION AND FUTURE SCOPE 6.1 Conclusion Data compression is very important in the computing world and it is commonly used by many applications, including the suite of SyncBack programs. In providing a brief overview on how compression works in general it is hoped this project allows users of data compression to weigh the advantages and disadvantages. 6.2 Future Scope In this project, many of the current important image compression and encryption techniques have been presented and analyzed. The best way of fast and secure transmission is by using compression and encryption of multimedia data like images. The compression technique observed is either lossy or lossless. Always lossless compression is preferred but to achieve secrecy some image quality degradation is accepted. Encryption applied by different researchers by means of encrypting algorithm which encrypt the entire or partial multimedia bit sequence using a fast conventional cryptosystem. Much of the past and current research targets encrypting only a carefully selected part of the image bitstream in order to reduce the computational load, and yet keep the security level high. In the proposed approach the key is required to send separately. This is a different issue of securely transmitting the secret key. Future scope of the proposed work is that we can design the mechanism to securely transmit the key so that unauthorized person should have no access to it.
  • 42. 33 References  http://www.javabeat.net/java-compress-image/  http://www.tutorialspoint.com/java_dip/image_compression_technique.htm  http://www.lac.inpe.br/JIPCookbook/6040-howto-compressimages.jsp  http://www.javatpoint.com/steps-to-connect-to-the-database-in-java  http://www.tutorialspoint.com/jdbc/jdbc-db-connections.htm