简体   繁体   中英

Compressed image format

Say I have a 16 bit greyscale image of 2 x 2 pixels that are perfectly random. The information content is 2 x 2 x 2 bytes = 8 byte.

Next I bilinear interpolate 8 x 8 time pixels in between my 2 x 2 initial pixels that now form the border. For each pixel I look up a 3 byte RGB value from a rainbow colormap. If I were to store this image uncompressed it would now take 10 x 10 x 3 bytes = 300 bytes.

However the information content has not increased by much. A super intelligent compression algorithm should be able to look at my 100 pixels and deduce what I have done and store the initial 2 x 2 greyscale pixels + a color map.

Which compressed existing image format should I use for storing such an image?

Depends on whether you need the image to be lossy or lossless. I will assume you want lossless. It depends on what you are doing with the image and how you are generating it. The short answer is that 16 bit PNG no transparency is the best generic format. If you are using lossy, JPEG is often better but it depends on the extent to which the image is continuous tone like a photo. Google WebP is an amazing format that often blows away the other but there is not good support for it yet.

For example, if you are using the image as a texture for a game the game toolkit you want a pvr texture. in iOS PNG files are used but use a different byte order so by default PNG files are re encoded so if you are generating your own PNG files, you can turn off the recompression if you make sure you are writing in the correct byte order.

Not all PNG encoders are equivalent. Some are smarter that others. So it depends on how much you care about saving size. Photoshop is convenient but does only a decent job in creating small PNG files. There are many opensource tools that do a better job. I choose based upon situation. Usually depending on how good the GUI and batch options are. When I am compressing in code, it depends on the environment I am using. If I am in .NET I look at the cost of specialized image toolkit and info on StackOverflow on how to teak the built in image classes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM