From: Craig on
I am trying to write a matrix I have out as a Tiff file, but MATLAB is only writing out the value 255 to the image file.

a = [1 2 3; 4 5 6]; %a is a double. I've tried uint8 and uint16 with the same results
imwrite(a,'file.tif','tif','Compression','none');
image = imread('file.tif')
image =
255 255 255
255 255 255

How can I write a to file.tif and retain the exact values?
From: us on
"Craig " <no(a)no.com> wrote in message <hp5436$iqg$1(a)fred.mathworks.com>...
> I am trying to write a matrix I have out as a Tiff file, but MATLAB is only writing out the value 255 to the image file.
>
> a = [1 2 3; 4 5 6]; %a is a double. I've tried uint8 and uint16 with the same results
> imwrite(a,'file.tif','tif','Compression','none');
> image = imread('file.tif')
> image =
> 255 255 255
> 255 255 255
>
> How can I write a to file.tif and retain the exact values?

one of the solutions

a=[1:3;4:6];
fnam='foo.tif';
imwrite(uint8(a),fnam,'tif','compression','none');
img=imread(fnam)
%{
% img =
1 2 3
4 5 6
%}

us