how to convert bpp(bits per pixel to compression ratio)?

답변 (1개)

Walter Roberson
Walter Roberson 2015년 5월 10일

0 개 추천

That depends upon the original image. Most images in common use are 8 bits (uint8) per color component, 3 color components per pixel, so 24 total bits per pixel. If you had 0.1870 bits per pixel instead, your compression ratio would be 24:0.1870 or about 128.3 to 1
Some kinds of image have only 1 color pane, and some kinds of images use more or fewer bits per component.
imfinfo() can be used to extract information about an image file. In particular look at the Bitdepth field.

댓글 수: 11

bitdepth is 8
can you give some mathematical forrmula?
Walter Roberson
Walter Roberson 2015년 5월 10일
편집: Walter Roberson 2015년 5월 10일
bitdepth / bpp
With a bitdepth of 8, you are probably working with a grayscale image. Just be careful when you write your compression code that if you handle a color image, the bits per pixel calculation has to take into account the 3 color planes.
yes I am working on a grayscale image
I found somewhere the formula bpp/bitdepth.
Compression ratios are traditionally expressed as (for example) 4:1 to mean 4 bytes became 1 byte, that the output is 1/4 of the original. As your bpp is going to decrease if you do a good job compressing, your bpp is going to be at most bitdepth, so bpp/bitdepth would be less than 1. That would give you the fraction output size (for example 1 bit per pixel used instead of 8 bits per pixel would give an output 1/8 of the original) but it would not be in traditional ratio format, which would be 8:1 in this example.
OK.. I got it. I want to know in any case bpp can be greater than 8(the bitdepth)
Yes, if the compression algorithm being used is not suitable for the data, then bpp can come out higher than bitdepth.
Every program that acts as a lossless compression routine on at least one input file must also cause at least one other input file to expand instead of getting shorter. This is a mathematical necessity. The trick is to find compression algorithms that compress files we are interested in. For example if an image compression program ended up expanding pictures of left-handed five-legged aardvarks, then we probably wouldn't care because we just don't get many of those in our world.
see Walter Roberson sir, I am sharing the source of my confusion. There is an inbuilt code for EZW image compression algorithm.
In the wcompress.m file(inbuilt file)
there are two formulae, which I am writing here
% Compute Compression Ratio.
%--------------------------
varargout{1} = 100*fileSize/numel(X); % Compression Ratio
varargout{2} = (fileSize*8*size(X,3))/numel(X); % Bits Per Pixel
line no 441. These both are opposite to each other. Now tell me what to do
Walter Roberson
Walter Roberson 2015년 5월 10일
편집: Walter Roberson 2015년 5월 10일
To interpret that, we would need more information about what fileSize means here, and about what X is.
Note: I do not have the Wavelet Compression Toolbox to look at that code. (Do not post the file, though, it is proprietary.)
tina jain
tina jain 2015년 5월 10일
편집: tina jain 2015년 5월 10일
X is the image. e.g lena image(256*256*1), file size is size of image after ezw compression

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Denoising and Compression에 대해 자세히 알아보기

질문:

2015년 5월 10일

편집:

2015년 5월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by