灰度图像的 BMP 格式是什么? [英] What is the BMP format for Gray scale Images?

查看:183
本文介绍了灰度图像的 BMP 格式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

灰度图像的 BMP 格式是什么(尤其是每像素 16 位)?维基百科只讨论了 bmp 的彩色图像.

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

更新:

只是为了给未来的访问者提供更新和信息,我要去PGM因为这是未压缩的并且可以支持 16 位灰度.另一种选择是使用 PNG,但它会压缩数据(这不是我想要的)正如此处所讨论的那样.另请注意,图像可能会失真,因为大多数显示器支持 256 色,而不支持 16 位的 4096 色.所以图像会饱和.

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.

令人惊讶的是,BMP 在 16 位图像灰度的情况下几乎无能为力.
感谢帮助我理解问题的人.

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.

推荐答案

对于灰度图像,我会使用 8 位 BMP.8 位 BMP 可以使用调色板对颜色进行编码.但是,如果您不使用,您可以简单地将颜色值 [0...255] 解释为从黑色 (0) 到白色 (255) 的颜色.

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).

我不会将 BMP 用于 16 位灰度图像.从技术上讲,您可以使用每像素 16 位 BMP 格式来编码 16 位灰度数据(http://en.wikipedia.org/wiki/BMP_file_format#Pixel_format).然而,实际上这是一个坏主意(阅读:hacky),因为该深度旨在对像素的 alpha、红色、绿色和蓝色样本进行编码.

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.

用于存储每像素 16 位灰度数据的更好格式是 PNG.

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

还要问问自己,你真的、真的需要那种超高精度吗?对于大多数应用程序,每像素 8 位就可以了(=如果您对精度没有任何特定要求,那就是这种情况).

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).

这篇关于灰度图像的 BMP 格式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆