MATLAB: Convert data on a TIFF image and save it

tiff

Hi,
I made some calculations regarding data I use for my research in image analysis.
Since I wanted to have an image that showed the variations of my variable, I transformed my data into values between 0-65535. I can not work with 0-255, because it is a very small range for what my original data is.
My problem is: I tried to create a grayscale image, and save it into a .tiff file. However not only I cannot obtain the file, but the image that MatLab is showing me does not have any variations. Is either all black or all white.
I'm sure my data is correct. I looked into the original variable, and everything is correct. I also looked into the variable that transforms those original data into values between 0-65535. I found several values ranging, primarily, between 10000 and 50000, so everything looks fine.
Does anyone knows how to convert N² data into an image of NxN size and show those variations? Also how to save it, .tiff file to be more specific?
My code up until now, regarding the problem:
% shows my grayscale image
figure;
image(tcrho); %tcrho is my variable, already in 0-65535 scale
colormap(gray(65536); %grayscale colormap
cbh = colorbar('location', 'SouthOutside'); %just location and name of my colorbar
set(cbh, 'Units', 'normal');
text(3.5, -1, 'Densidade crescente', 'Parent', cbh);
%save my image. I need to save several images – that explains the %04d.
rtc = sprintf('rho%04d.tiff',d);
imwrite(tcrho,gray(65536),rtc,'tiff')

Best Answer

What does
whos tcrho
show? I want to know if it's uint16 or double. By the way, you can't have a colormap with 65536 entries in it. Simply display your image like this:
imshow(tcrho, []);
and don't use a colormap at all.