我有大约4MB的image.mat。某些图像文件的大小也可以是4MB。可以将image.mat
其传输到图像文件吗?
我尝试了这个,但是并不能解决问题:
load image.mat %load Iw
imshow(mat2gray(Iw))
imwrite(Iw,'image.png');
IwNew = imread('image.png');
isequal(Iw,IwNew)
结果为0;结果为0。我误会了吗?
中的数字Iw
非常重要,因此Iw不能更改。
实际上,我真正的问题是如何将浮点数存储到图像中?
但是MATLAB不支持Tiff 6.0,因此我必须找到一些解决方法。我正在做盲注水印,并且其中一个数字的小数部分Iw
很重要,因为它涉及到另一张图像的信息。因此Iw
不能更改。
我的带有图像处理工具箱的MATLAB(R2010a)完全能够存储双值像素值,并在不丢失数据的情况下进行检索。
这是此答案的无耻副本:
% Some random, data of type double
A = 7.6*rand(10);
% Construct TIFF image...
t = Tiff('test.tif', 'w');
% ...with these custom parameters...
tagstruct = struct(...
'ImageLength' , size(A,1),...
'ImageWidth' , size(A,2),...
'Compression' , Tiff.Compression.None,...
'SampleFormat' , Tiff.SampleFormat.IEEEFP,... % floating point
'Photometric' , Tiff.Photometric.MinIsBlack,...
'BitsPerSample' , 64,... % 8 bytes / double
'SamplesPerPixel' , 1,...
'PlanarConfiguration', Tiff.PlanarConfiguration.Chunky);
t.setTag(tagstruct);
% ...and write it to disk.
t.write(A);
t.close();
% Read the data actually written, and check if all
% information was indeed preserved:
B = imread('test.tif');
isequal(A,B)
结果:
ans =
1
如果您具有多个通道(RGB),请以明显的方式进行调整。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句