image compression should bitmap image?

haii, I want to ask whether the image should be compressed bitmap format? because when I perform image compression with format PNG and JPEG formats generated ratio does not correspond to my formula the ratio = original image size / image compress. But if the ideal format png / jpeg fox was my first to the bitmap with Photoshop, the ratio produced in accordance with my formula.

Antworten (1)

Walter Roberson
Walter Roberson am 12 Jan. 2017

0 Stimmen

No. It is just that image compression ratio is not meaningful when you compare the image files. Image files are container formats that can include all kinds of extra information such as copyright, date taken, focal length, comments, pixel resolution, preview images. You could potentially have compressed the image portion of the file by a factor of 100 and yet end up with a larger file, if the writing of the container adds in more information than was there before.
In short, comparing the directory bytes information about two image files does not tell you anything reliable about the image compression ratios of the images stored in image files.

3 Kommentare

Andi Juwandi Karmita
Andi Juwandi Karmita am 13 Jan. 2017
Bearbeitet: Walter Roberson am 13 Jan. 2017
help me, what should I change so that the system can make the process of compression of JPEG / PNG. indeed the system can perform the compression. but it is still not precise calculations. because sometimes his size even bigger if the image is compressed jpeg / png
function y = im2jpeg(image, quality)
img = image ;
[Height,Width,Depth] = size(img);
img1 = img(1:Height, 1:Width, :);
clear img;
img=img1;
if Depth > 1
img = rgb2ycbcr(img);
y = img (:,:,1);
cb = img (:,:,2);
cr = img (:,:,3);
x = uint8 (y);
else
x = uint8 (img);
cb = char;
cr = char;
end
m= [16 11 10 16 24 40 51 61
12 12 14 19 26 58 60 55
14 13 16 24 40 57 69 56
14 17 22 29 51 87 80 62
18 22 37 56 68 109 103 77
24 35 55 64 81 104 113 92
49 64 78 87 103 121 120 101
72 92 95 98 112 100 103 99] * quality;
order = [1 9 2 3 10 17 25 18 11 4 5 12 19 26 33 ...
41 34 27 20 13 6 7 14 21 28 35 42 49 57 50 ...
43 36 29 22 15 8 16 23 30 37 44 51 58 59 52 ...
45 38 31 24 32 39 46 53 60 61 54 47 40 48 55 ...
62 63 56 64];
[xm, xn] = size(x);
x = double (x) - 128;
t = dctmtx(8);
y = blkproc (x, [8 8], 'P1 * x * P2',t, t');
y = blkproc (y, [8 8], 'round(x ./ P1)',m);
y = im2col (y, [8 8], 'distinc');
xb = size (y, 2);
y = y (order, :);
eob = max (y(:)) +1;
r = zeros (numel (y) + size (y, 2), 1);
count = 0 ;
for j = 1:xb
i = max (find(y(:, j)));
if isempty (i)
i = 0;
end
p = count + 1;
q = p+i;
r(p:q) = [y(1:i, j); eob];
count = count + i +1;
end
r ((count +1) :end) = [] ;
y = struct;
y.size = uint16([xm xn]);
y.numblocks = uint16(xb);
y.quality = uint16(quality * 100);
y.huffman = mat2huff(r);
y.chromaBlue= cb ;
y.chromaRed = cr;
%save compressed file
save ('C:\Users\andiju\Documents\FINAL TEST\kompresJPEG.mat','y');
end
Image Analyst
Image Analyst am 13 Jan. 2017
Use imwrite() to save arrays in an image format. Don't use save(), which saves it in a MATLAB proprietary format. What you're saving is a structure in a proprietary format, not an image that's been compressed and saved to an image file in JPG format.

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 12 Jan. 2017

Kommentiert:

am 13 Jan. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by