Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
782 views
in Technique[技术] by (71.8m points)

bitmap - What is the BMP format for Gray scale Images?

What is the BMP format for Gray scale Images (especially for 16 bit per pixel) ? The wikipedia just talks about colour images for bmp.

Update:

Just for an update and information for future visitors, I am going for PGM as this is uncompressed and can support 16 bit gray-scale. Another option was to use PNG, but it compresses the data (which is not what I want) as discussed here . Also note that the image may appear distorted, since most of the monitors support 256 colors and not 4096 for 16 bit. So the Image will be saturated.

It was though surprising to know that BMP is almost helpless in case of Gray-scale for 16 bit images.
Thanks for people who helped me understand the issue.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

For grayscale images, I would use 8-bit BMP. 8 bit BMPs can encode colors with palette. However, if you don't use one, you can simply interpret color values [0...255] as colors from black (0) to white (255).

Edit: I wouldn't use BMP for 16-bit grayscale images. Technically, you could use 16-bits per pixel BMP format for encoding 16-bit grayscale data (http://en.wikipedia.org/wiki/BMP_file_format#Pixel_format). However in practice this is a bad idea (read: hacky) since that depth is designed to encode alpha, red, green and blue samples of the pixels.

A better format for storing 16-bit per pixel grayscale data is PNG.

Also ask yourself, do you really, really need that extra-precision? For most applications, 8 bits per pixel is just fine (=if you don't have any specific requirements on precision, this would be the case).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...