MATLAB 存储16unit图像的问题

我读取一副16unit的灰度图像(基本为黑色),将之进行切割存入另一文件名中,可是却只能存为double类型的8位图,而且新图像所有像素点都为值为255的亮点。我想问一下可有高手知道原因?

如果不知道,可不可以告诉我如果设定用imwrite将图像存成16位的灰度图?

最后还有一个问题,图像是16位的灰度图,为什么MATLAB用imread打开后矩阵中每个像素还是0-255?不应该是0-65536么?

非常感谢!好的再加分!

我读取一副16unit的灰度图像(基本为黑色),将之进行切割存入另一文件名中,可是却只能存为double类型的8位图

在Matlab命令窗口输入命令:

help imwrite

会有如下解释:

    If the input array is of class uint16 and the format supports 16-bit data (JPEG, PNG, and TIFF), imwrite outputs the data as 16-bit values. If the format does not support 16-bit values, imwrite issues an error. Several formats, such as JPEG and PNG, support a parameter that lets you specify the bitdepth of the output data.

    If the input array is of class double, and the image is a grayscale or RGB color image, imwrite assumes the dynamic range is [0,1] and automatically scales the data by 255 before writing it to the file as 8-bit values.

“将之进行切割”后生成的矩阵是什么类型的呢?不是unint16类型的话,要转化为uint16类型。然后再用imwrite命令将其保存为unit16的图像。

例如:

data11=uint16(data1);
imwrite(data11,'image.png','png','bitdepth',16);

如果不知道,可不可以告诉我如果设定用imwrite将图像存成16位的灰度图?

见上面回答。

最后还有一个问题,图像是16位的灰度图,为什么MATLAB用imread打开后矩阵中每个像素还是0-255?不应该是0-65536么?

你确定你imread的图像是位深度16的图像吗?imread之后是如下图data11那种类型格式吗?如果是data11这种类型的,肯定每个像素是0-65536之间的值。

详情请见:Matlab如何imwrite,Uint16的图像

温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-01-31
你保存为什么格式的?bmp不可以保存为16位灰度图片,你保存为tif格式即可。还有保存前先将double型转换为uint16型,不然默认是uint8型的。本回答被提问者采纳
第2个回答  2010-01-31
imread读入的都是unit8(0-255)的,你需要用转换函数转过去
相似回答