我有一个nCol by nRow矩阵的双打,我想通过像素的nRow灰度图像转换成nCol。我不想将其缩小为缩放到256个频道的图像。我很高兴使用单打而不是双打。我已经查看了Mathworks的Tiff类文档,但是找不到一个简单的例子。
答案 0 :(得分:1)
我试着阅读关于Tiff类的内容,是的,它的记录很差。但我发现这经历了反复试验:
假设我们有矩阵
data = rand(100,200);
让我们把它保存为Tiff:
t = Tiff('new.tif','w') %create object of Tiff class
setTag(t,Tiff.TagID.ImageLength,size(data,1)) %define image dimentions
setTag(t,Tiff.TagID.ImageWidth,size(data,2))
setTag(t,'Photometric', Tiff.Photometric.MinIsBlack) %define the color type of image
%specifies how image data components are stored on disk
setTag(t,'PlanarConfiguration',Tiff.PlanarConfiguration.Chunky);
setTag(t,'BitsPerSample',64); %because 1 double = 8byte = 64bits
%Specify how to interpret each pixel sample (IEEEFP works with input doubles)
setTag(t,'SampleFormat',Tiff.SampleFormat.IEEEFP);
t.write(data)
t.close
让我们现在测试一下:
datac = imread('new.tif')
whos datac
Name Size Bytes Class Attributes
datac 100x200 160000 double
和
datac(:,1)
ans =
0.4921
0.6908
0.1544
0.4433
...