From: amandeep on
can anyone help me in finding the relation b/w bpp and compression ratio.
i had implement image compression algo's using different values of bpp. But i m unable to understand the relation b/w bpp n compression ratio
plz help me
From: Walter Roberson on
amandeep wrote:
> can anyone help me in finding the relation b/w bpp and compression
> ratio. i had implement image compression algo's using different values
> of bpp. But i m unable to understand the relation b/w bpp n compression
> ratio

It depends on whether the output file format is able to effectively pack
together the bits. _Assuming_ that it is, then the calculation becomes
fairly simple:

After compression, each pixel requires bpp bits. Multiply bpp by the
number of pixels, divide by 8 (bits per byte), round up, and add the
size in bytes of any file header (e.g., that might contain information
about the dimensions and compression algorithms and so on.) This gives
you the total size occupied by the compressed image. [This all presumes
that bpp is a constant, which isn't generally true for modern image
storage techniques...]

Now find out how many bits are occupied per pixel in uncompressed
format. For example, if the original data is stored with R, G, and B
components each of which is expressed by a double precision number, then
the image is going to take 64 bits per double times 3 doubles = 192 bits
per pixel. Divide by 8 (bits per byte), round up, and add the size in
bytes needed for the file header for the uncompressed image, to get the
total file size of the uncompressed image.

Now, the compression ratio is the file size of the uncompressed image,
divided by the file size of the compressed image.

If you neglect the size of the file header, which is mathematically
justifiable for "sufficiently large" images, then the compression ratio
can be calculated more directly as the number of bits occupied by each
pixel before compression (e.g., the 192 figure above for some file
formats), divided by the post-compression bpp figure. For example, if
post-compression each pixel was represented by 12 bits (e.g, 5 bits of
blue, 4 bits of green, and 3 bits of red {there is justification in the
visual system for using different number of bits for the different
colors), then the compression ratio would, in this example, be 192 / 12
which is 16:1.
From: amandeep on
Sir , i m using the whos() matlab function.
from this i m dividing the bytes occupied by both images for calculating rhe compression ratio.

if orginal image is gray level image then it ll use 8 bpp and in compression algo if i m using 0.1 as bpp, then what ll be the compression ratio
Walter Roberson <roberson(a)hushmail.com> wrote in message <hnq1no$5mc$1(a)canopus.cc.umanitoba.ca>...
> amandeep wrote:
> > can anyone help me in finding the relation b/w bpp and compression
> > ratio. i had implement image compression algo's using different values
> > of bpp. But i m unable to understand the relation b/w bpp n compression
> > ratio
>
> It depends on whether the output file format is able to effectively pack
> together the bits. _Assuming_ that it is, then the calculation becomes
> fairly simple:
>
> After compression, each pixel requires bpp bits. Multiply bpp by the
> number of pixels, divide by 8 (bits per byte), round up, and add the
> size in bytes of any file header (e.g., that might contain information
> about the dimensions and compression algorithms and so on.) This gives
> you the total size occupied by the compressed image. [This all presumes
> that bpp is a constant, which isn't generally true for modern image
> storage techniques...]
>
> Now find out how many bits are occupied per pixel in uncompressed
> format. For example, if the original data is stored with R, G, and B
> components each of which is expressed by a double precision number, then
> the image is going to take 64 bits per double times 3 doubles = 192 bits
> per pixel. Divide by 8 (bits per byte), round up, and add the size in
> bytes needed for the file header for the uncompressed image, to get the
> total file size of the uncompressed image.
>
> Now, the compression ratio is the file size of the uncompressed image,
> divided by the file size of the compressed image.
>
> If you neglect the size of the file header, which is mathematically
> justifiable for "sufficiently large" images, then the compression ratio
> can be calculated more directly as the number of bits occupied by each
> pixel before compression (e.g., the 192 figure above for some file
> formats), divided by the post-compression bpp figure. For example, if
> post-compression each pixel was represented by 12 bits (e.g, 5 bits of
> blue, 4 bits of green, and 3 bits of red {there is justification in the
> visual system for using different number of bits for the different
> colors), then the compression ratio would, in this example, be 192 / 12
> which is 16:1.
From: Walter Roberson on
amandeep wrote:
> Sir , i m using the whos() matlab function.
> from this i m dividing the bytes occupied by both images for calculating
> rhe compression ratio.
>
> if orginal image is gray level image then it ll use 8 bpp and in
> compression algo if i m using 0.1 as bpp, then what ll be the
> compression ratio

I already gave you the solution for that in the message you were
replying to:

> Walter Roberson <roberson(a)hushmail.com> wrote in message
> <hnq1no$5mc$1(a)canopus.cc.umanitoba.ca>...

>> If you neglect the size of the file header, which is mathematically
>> justifiable for "sufficiently large" images, then the compression
>> ratio can be calculated more directly as the number of bits occupied
>> by each pixel before compression (e.g., the 192 figure above for some
>> file formats), divided by the post-compression bpp figure.

Number of bits per pixel before compression: 8
Number of bits per pixel after compression: 0.1
Compression ratio: substitute the numbers into the formula I gave.