我读取一副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将图像存成16位的灰度图?
见上面回答。
最后还有一个问题,图像是16位的灰度图,为什么MATLAB用imread打开后矩阵中每个像素还是0-255?不应该是0-65536么?
你确定你imread的图像是位深度16的图像吗?imread之后是如下图data11那种类型格式吗?如果是data11这种类型的,肯定每个像素是0-65536之间的值。