MATLAB is a powerful tool for analyzing images and signals for developing applications. One of the applications of image compression with MATLAB using a graphical user interface is described in this article. Here we talk about lossless image compression using MATLAB.
Cameras are nowadays being provided with more and more megapixels to improve the quality of captured images. With improvement in image quality, size of the image file also increases.
Due to speed limitation of the Internet, it takes more time to upload good-quality images that are of bigger sizes. A user needs to compress the image without degrading its quality. Mobile manufacturers need algorithms in their cameras that enable storing the images in reduced sizes without degrading their quality.
There are two types of compression algorithms, namely, loss-less and lossy-image compression. This article proposes a technique to compress the captured image to reduce its size while maintaining its quality. A number of images were considered to check the veracity of the proposed algorithm.
In this article, discrete cosine transform algorithm is used, which compresses the image with a good compression ratio.
The flowchart of the process is shown in Fig. 1.
The image is read through MATLAB to capture its pixels. After obtaining the compressed image, peak-signal-noise ratio (PSNR) and mean-square error (MSE) are calculated using the following relationships:
where m and n are the number of rows and columns. Image1 and Image2 are the original and compressed images, respectively.
After compression, there should not be much change in the quality of the image. MSE indicates an error between the original image and compressed image. It should be as small as possible.
where R is the maximum fluctuation in the input image data type (maximum possible pixel value of image). PSNR is related to MSE and it gives the amount of noise in a compressed image. PSNR should be as high as possible.
All equations are implemented in MATLAB in the form of functions.
Some images and their associated MATLAB graphical interfaces are shown in Figs 2 to 5.
Download source code: click here
Lalit G. Patil is a lecturer in Department of Electrical Engineering, M.S. University of Baroda, Gujarat. His areas of research include signal processing, image processing and control systems
where can i get this image compression code?
Dear Bharat Reddy, the source code is present at the end of the article.
Can I use this code for the DIcom image comperrsion (non colour image)
No you can not use.
You can use it only for Jpg images.
What should I do to compress whole video once I convert it in to frames?
Can I get some guidance about video compression please…….
Thank You
Hii..Kailash…did u get any idea about video compression…pls help me also….
i am searching for this …for my thesis work….
please help me…
my id is [email protected]
Here’s the reply from author Lalit Patil:
Yes, Write a “for Loop” code to compress frames one by one. When complete compression of frames is done then merge frames into video. It will be compressed video.
Sir…i also want to do the compression process for a video….please help me…also i need the decompression code also…
Decompression is not possible once it is compressed.
For video compression, you can convert video into frames.
Then compress each frame.
Then merge all frames into video again.
Check video size. It will be compressed.!!
can u give methe simulink of this project?
its dynamic model equation?
transformation eqn wrt transfer func
stability of function
error calculation
root locus plots
Kindly elaborate your query.
Your Question seems related with Control system of Machine. It has nothing to do with Image processing.
Whenever I try to lead the picture
the program does nothing it doesnt upload it
the computer makes sound (question)
so it cant compress when it cant load the image
Open ImageCompression1.m Matlab code. Run the program by clicking ‘Run’ button. A screen opens up. Click on ‘Select the image’ option on the left side. You need to load any .jpg format image file from your PC. Once image is loaded, you can see the image on the screen. Now, click on ‘Compress image’ option on the right side. Wait for some time until the compressed image pops up on the screen.
I cant select the image , when i click the select image button the shows an error in GUI_STATE function and gui_mainfcu the code is running but i cant select the picture
hello, please apart from matlab, what other software do i need to install in the authenticating e-assessment users via keystrokes and facial biometrics recognition
Please post your query on the topic and article
Is it related with Image Compression.?
i have tried your code and it work…
can you explain me about method that use on code?
what method do you use?
thanks
It is given in article with proper algorithm. it is DCT method.
where is the code?????????
can u send MATLAB code for image compression by adaptive filter
Please send such request to [email protected]
Adaptive filter is for filtering noise in images. If you want to compress data, then i don’t know how it works. But you can look for research papers. If they have done, then there might be an algorithm. You will get idea if you have enough knowledge about filters and their implementation. All you have to do is play with MATRIX only.
sir can u send the compression video
Convert Video into Frames. Code is available in google search. Then make a Loop program to compress each frame. Then Make video from Frames.. it will be a compressed video. Best of Luck..
how we can prove that the compression is lossless?
Get SNR from both images and is should be as high as possible.!!
Applicable to Audio and Image both.
how to use .fig file??
you should have standard jpg file.. if you have another format then find a way to convert into jpg.
i am getting the following errors:
>> ImageCompression1
Insufficient number of outputs from right hand side of equal sign to satisfy assignment.
Error in ImageCompression1>pushbutton1_Callback (line 89)
SIZE = fileinfo.bytes;
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in ImageCompression1 (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)ImageCompression1(‘pushbutton1_Callback’,hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
Can someone help?
ASAP
could you rectify the error?
Warning: MATLAB has disabled some advanced graphics rendering features by switching to software OpenGL. For more information, click here.
Undefined function ‘dctmtx’ for input arguments of type ‘double’.
Error in ImageCompression1>pushbutton2_Callback (line 110)
T = dctmtx(8);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in ImageCompression1 (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)ImageCompression1(‘pushbutton2_Callback’,hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
what to do about this errors??
This is the reply from the author Lalit Patil.
“This is the code written in MATLAB 2013 version.! As the years passes, functionality is changed in newer versions. You might be using some higher version. Try in MATLAB 2013.”
is there no way to make it work in 2016/17 version?
How to save the compressed image?
can anyone give me another image compressor matlab code using PNG or TIFF method? or can anyone help me about compress image using png and tiff through matlab code?
I used png and bmp format, it got compressed with the given code ?
is there any ource code using huffman coding algorithm????????
plz rply
and after selecting image is not compressed….itz shows nothng
plz help
Here’s the Huffman Encoding & Decoding in MATLAB
Sir, I am having trouble in displaying video on the axes.
Because the axes is not the size of video, the video resizes and become pixelated.
How can I have an axes resizing based on the input video?
here is my code.
handles.output = hObject;
axes(handles.axes1);
vid = videoinput(‘winvideo’, 2);
himage = image(zeros(160,120,3),’parent’,handles.axes1);
preview(vid,himage);
guidata(hObject,handles);
The program is working fine but the images are not being shown in the MATLAB window. Please help!!
yeah same problem , images are not been displayed in figure window.
have you rectified it ..if so please mail modified code to [email protected]
thanks
sir, can you give me the code for image compression using DWT? please!
in gui images are not displaying
Kindly elaborate your query.
the code which you gave for Lossless Image Compression Using MATLAB is working but in the figure window images are not displaying ..
what to do ….pls help me
i have used the code which is present in this site
its not displaying images in figure window
the link is not working
Hi Amine, please refresh the page.
too many errors in 2013 matlab as well ..
what to do ??
Kindly elaborate your query.
Sir please send the code to this mail id [email protected]
I’m unable to open the code
Kindly refresh the page and re-download.
How to decompress ?
Once it is compressed, You can not decompress. Because you have modified pixels in mathematical form. Compress and Decompress means only reduction in Size of image without reducing Quality. So no need to Decompress.!!
How to calculate PSNR,CR,etc?
i have used the code for Lossless Image Compression Using MATLAB which is present in your site
its compressing the image file ,
but its not displaying
images of uncompressed and compressed images in figure window.
its displaying only size of uncompressed image
pls help me
i love your website
thanks
same problem with me…
why aren’t the pictures displaying during compression im matlab??
hey sir i need matlab code on image compression for capsule endoscopy using Integer wavelet packet transform embedded with DPCM
sir, I need Matlab source code for medical image compression using guassian hermite polynomial (for compression CT Scan image).plssss share the code.i need imediately
the images are not displaying help!!!
Please refresh the page.
greetings sir
please i wish to seek for a working matlab code to do bilevel lossless image compression, i prefer using huffman coding. please i will appreciate your help. thank you in anticipation
Which image compression technique is used here?
Sir please send the code to this mail id [email protected]
I’m unable to open the code.
page refreshing again and again but not working…
Hi Sadia,
Please turn off anti-virus from your computer while opening the zip file. Maybe the anti-virus is deleting the source files.
how to use it on online matlab tool
Sorry, we have not tried with online MATLAB tool
After execution of the code, in the output, the images are not displaying….can i know the reason?
because you are using a newer version…..try running this into older version
sir i have used the code for Lossless Image Compression Using MATLAB which is present in your site
its compressing the image file ,
but its not displaying
images of uncompressed and compressed images in figure window.
its displaying only size of uncompressed image
This is the code written in MATLAB 2013 version. The functionality is changed in newer versions. Try in MATLAB 2013.
I need the code explanation..can any one help me please?
Sir, I run the code for image compression but it is showing the images in figure window. It is showing the size of compressed image and original image but not the images ?
Why ? Kindly tell me !!!!
can plz send lzw lossless code for image compression in matlab
Hi Priya, the Matlab program is present at the end of the article.
Can anyone provide a report on the above project?
Hi Shashank, all the information related to this project is already shared within the article.
sir, the code isn’t working for me to download it
I hope you can fix this
Please refresh the page and redownload.
sir quantization is used here so it is lossless image compression?
@Sushil: Refer below link for answer.
https://www.quora.com/What-is-the-importance-of-quantization-in-lossy-and-lossless-compression
How can i download compressed image
Sir Can you please help me how to use and run this code
i’m from python background and don’t know much about Matlab
On the Editor or Live Editor tab, in the Run section, click Run.