Matlab source code for Image compression algorithm

191 views (last 30 days)
I need a source code for image compression algorithm that will read the image and then compress it and save it in another folder. There is no need to display the image while executing. It would be more helpful if the source code works on multiple files through a loop. p.s i am working in matlab 2010a

Accepted Answer

Image Analyst
Image Analyst on 16 Mar 2014
originalImage = imread(inputfilename);
[inputFolder, baseFileName, ext] = fileparts(inputfilename);
% Write as compressed JPG or PNG or whatever.
outputFileName = fullfile(outputFolder, [baseFileName, '.jpg']);
imwrite(originalImage, outputFileName);
  13 Comments
doaa
doaa on 6 Nov 2022
if you be exist to the code ,can you sent to me because i need it and doesn't reach for any code
Walter Roberson
Walter Roberson on 6 Nov 2022
doaa, we have been discussing multiple programs, and we do not know which one you want.

Sign in to comment.

More Answers (2)

Sufyan Parkar
Sufyan Parkar on 26 Sep 2019
Edited: DGM on 8 Apr 2024 at 4:47
Well Steven Lord,
I have tried to write a code myself.
Please try to assist me here.
clc;
clear all;
close all;
a = imread("location");
ag = rgb2gray(a);
imshow(a)
z = zeros(size(ag));
[x y] = size(ag);
for i = 1:x
z(i,1) = ag(i,1);
for j = 2:y
z(i,j) = ag(i,j-1) - ag(i,j);
end
end
disp(z)
figure()
imshow(z)
  1 Comment
Walter Roberson
Walter Roberson on 26 Sep 2019
That code does no image compression. It tries to find the difference between adjacent pixels, perhaps in preparation for delta encoding. However, you will find that ag is likely uint8 and when you subtract a larger uint8 from a smaller you get 0 rather than negative. If you were to take care to double(ag) then you could get negative. However you are storing the results in double() and imshow of double with negative values might not give you the results you expect. Does it make sense to display the difference between adjacent pixels as if it were itself an image?
By the way: read about diff()

Sign in to comment.


khadija elazrag
khadija elazrag on 27 Oct 2019
Hi i need source code for DNA comprission by using huffman algorithm
  4 Comments
khadija elazrag
khadija elazrag on 28 Oct 2019
thanks a lot i have question. how i can enter my inputs like probability and symbole from datasets
and how can i apply this code on DNA from datasets, is it manoualy or there is command to do that, my problem is how i can find and enter datasets for huffman code.
Walter Roberson
Walter Roberson on 28 Oct 2019
huffmandict() can calculate probabilities.
You can probably created a datastore object and use a small loop to process the entires. See https://www.mathworks.com/help/matlab/ref/matlab.io.datastore.read.html

Sign in to comment.

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!