Andy
Andy

Reputation: 3829

Ideal image format for color image that is really greyscale

I have a matrix of m x n float data values that I want to apply a rainbow colormap to and then store as a color image.

The data values are almost random.

What would be the ideal image format for storing such an image? I want the resulting image file to be as small as possible withouth loosing visual information.

Upvotes: 0

Views: 38

Answers (1)

David Berger
David Berger

Reputation: 756

Depends on what the images is getting used for. WebP has amazing lossless capabilities but the support is not great. IOS and most browsers does not support it although late android and Chrome does. For a generic lossless format you should use PNG. JPEG at a high quality setting is also fine depending on what you mean by loosing info. If you need exact pixel accurate color values you need to go lossless and cant use JPG.

To make the image as small as possible you can use a lower bit depth. By default most PNG files are 32 bit which is 24 bit of color and 8 bit of transparency (alpha channel). If you do not need transparency you can dump the alpha channel and go 24 bit. If you do not need as many colors use a lower bit depth. 16 bit will get you most colors you need for most purposes. You can take an image that is more than 16 bit and map it to 16 bit and for most purposes you can not tell. It depends on how many colors appear in the image even though they are random. At 8 bit and below PNG files uses a color lookup table so the colors can be random but if there are fewer than 256 or if you can live with some remapping go 8 bit PNG. Take this furthure, if there are fewer than 128 colors go 7 bit all the way down to 1 bit.

Also you can save tiny amount of size by stripping the metadata and other info. There are a bunch of open source tools to do so.

Upvotes: 1

Related Questions