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

Réponses (1)

Walter Roberson
Walter Roberson le 10 Mai 2015

0 votes

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 commentaires

bitdepth is 8
can you give some mathematical forrmula?
Walter Roberson
Walter Roberson le 10 Mai 2015
Modifié(e) : Walter Roberson le 10 Mai 2015
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.
tina jain
tina jain le 10 Mai 2015
Modifié(e) : Walter Roberson le 10 Mai 2015
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 le 10 Mai 2015
Modifié(e) : Walter Roberson le 10 Mai 2015
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 le 10 Mai 2015
Modifié(e) : tina jain le 10 Mai 2015
X is the image. e.g lena image(256*256*1), file size is size of image after ezw compression

Connectez-vous pour commenter.

Catégories

En savoir plus sur Denoising and Compression dans Centre d'aide et File Exchange

Question posée :

le 10 Mai 2015

Modifié(e) :

le 10 Mai 2015

Community Treasure Hunt

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

Start Hunting!

Translated by