Confusion over the compression ratio of an Image.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
So here's the deal, I have 2 separate codes for an image, one takes in 2 images (compressed and uncompressed) and then determines the compression ratio. my qualms with it is that the compression ratio is always 8, no matter the quality factor I've used. Its still 8 even thou the image sizes do not reflect that.
The other code, takes a compressed image, uses parameters from imfinfo function to determine the compression and I get something around 45. Which is supposedly not an unreasonable value for JPEG compression.
I'm confused here, which method is more representative if the JPEG compression scheme I am trying to do?
Can an image carry compression information as is the case for the second method?
first method:
function cr = imratio(f1,f2)
error(nargchk(2,2,nargin));
cr = bytes(f1)/bytes(f2);
function b = bytes(f)
if ischar(f)
info = dir(f);
b = info.bytes;
elseif isstruct(f)
b = 0;
fields = fieldnames(f);
for k = 1:length(fields)
b = b+bytes(f.(fields{k}));
end
else
info = whos('f');
b = info.bytes;
end
end
% set(handles.imratiotextbox,'String',cr);
end
second method:
k = imfinfo('3c.jpg');
ib=k.Width*k.Height*k.BitDepth/8;
cb=k.FileSize;
cr=ib/cb
6 Commenti
Walter Roberson
il 24 Nov 2015
Do you mean strings that are file names? If so then how are those images represented on disk?
Do you mean arrays that resulted from imread()? If so then what is class() for each of them?
Risposte (1)
Walter Roberson
il 24 Nov 2015
For method 1, one of your arrays is uint8() and the other is double(). The one with double() takes 8 times as much memory to store.
2 Commenti
Image Analyst
il 24 Nov 2015
Give an exact call for cr = imratio(f1,f2). We're still not clear if you're passing in filename strings, or some kind of structure - your "bytes" function is written to handle both.
Vedere anche
Categorie
Scopri di più su Denoising and Compression in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!