How to calculate the compression ratio for compressed image?

3 views (last 30 days)
hi,
I am working on image processing project, I need to find the compression ratio of compressed image.

Answers (1)

Image Analyst
Image Analyst on 31 Dec 2013
After you've saved your image onto disk in your compressed format, look at the file size and compare it to the other file which is compressed with a different method or uncompressed:
fileName = 'moon.tif';
fileInfo = imfinfo(fileName)
strInfo = sprintf('\n%s is an %d bit image.\nFile size = %d bytes, and %d columns wide by %d lines tall', ...
fileName, fileInfo.BitsPerSample, fileInfo.FileSize, fileInfo.Width, fileInfo.Height);
fprintf('%s\n', strInfo);

Community Treasure Hunt

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

Start Hunting!