Info
This question is locked. 请重新打开它进行编辑或回答。
Matlab source code for Image compression algorithm
20 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Image Analyst
2014-3-16
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 个评论
doaa
2022-11-6
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
2022-11-6
doaa, we have been discussing multiple programs, and we do not know which one you want.
更多回答(2 个)
Sufyan Parkar
2019-9-26
编辑:DGM
2024-4-8
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 个评论
Walter Roberson
2019-9-26
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()
khadija elazrag
2019-10-27
Hi i need source code for DNA comprission by using huffman algorithm
6 个评论
Image Analyst
2024-7-30
@mousa just save your image variable as a JPG or PNG image file
imwrite(rgbImage, 'compressed image.jpg'); % Lossy compression
imwrite(rgbImage, 'compressed image.png'); % Lossless compression
This question is locked.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Large Files and Big Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!