Cheap and Secure Web Hosting Provider : See Now

How are the number of bytes less than the number of pixels in an image?

, , No Comments
Problem Detail: 

Lets take, for example this jpeg image here

example

The image there is 400 x 300, or 120000 pixels and The file size of the image (on my computer) is shown to be 65171 bytes.

This means the computer stores about 2 pixels in every byte. How does it do this? Is it due to the same color pixels repeating in the image, so it only has to save the RGB data once, or is there some other trickery going on here?

Asked By : Adam Brady
Answered By : leonbloy

A colour image is typically digitalized using 256 levels for each of the 3 RGB channels. That gives 3 bytes per pixel. The trick to attain smaller file size is to apply some compression, to take advantage of the redundacy (neighbouring pixels tend to have similar colours). That depends on the image format. For example, PNG format applies a "lossless" compression (no information lost). JPEG format applies a more aggresive lossy compression (some information lost). BMP format is a format that does not (by default) compress; you can try to open your image and save it in BMP format and check that the size is approximately the expected (3 bytes per pixel). Other thing you can try is to generate a big "pure noise" image, and check that the size is also about 3 bytes per pixel (compression does not work here).

Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/60661

3200 people like this

 Download Related Notes/Documents

0 comments:

Post a Comment

Let us know your responses and feedback