Reputation: 5512
I am producing 3500x7500 size double matrices in a loop that I want to export as tif files.
A section of the code
for k = 1:length(basinlist{1})
#some operation that produces GRID
imwrite(GRID,filename);
end
But, when I do this, the TIF file produced contains only 255 and output is in uint8. I read about it in the documentation, but I am not able to fix it. All I want is to retain the original values with no scaling or anything.
If this helps:
>> max(max(GRID))
ans =
1.5646e+04
>> min(min(GRID))
ans =
1.1119e+03
Upvotes: 1
Views: 952
Reputation: 2331
Suppose we want to create image with such colour depth that will fit to given data.
Data exported to image format are converted to uint8
by default (data range 0-2^8-1).
But Matlab (2011b) can operate with more uintX
formats where X
stands for X bits per value.
uint8
with span 0-255 (2^8)uint16
with span 0-65 535 (2^16)uint32
with span 0-4.29 e 9 (2^32)uint64
with span 0-1.84 e 19 (2^64)Code to export data without any loss:
for k = 1:length(basinlist{1})
#some operation that produces GRID
%% Convert GRID to roughest acceptable uint format
GRID=uint16(GRID);
%% Export
imwrite(GRID,filename);
end
Upvotes: 1