Effacer les filtres
Effacer les filtres

Convert data on a TIFF image and save it

5 vues (au cours des 30 derniers jours)
Haimon
Haimon le 5 Avr 2014
Commenté : Haimon le 11 Avr 2014
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')

Réponse acceptée

Image Analyst
Image Analyst le 5 Avr 2014
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.
  6 commentaires
Image Analyst
Image Analyst le 10 Avr 2014
Sorry - it turns out mat2gray scales between 0 and 1, not 0 and 255. So if you want a regular 8 bit image, you have to multiply by 255. So if you want a 16 bit image, you have to multiply by 65535.
imwrite(uint8(255*mat2gray(tcrho)), filename);
Haimon
Haimon le 11 Avr 2014
Thank you for your help!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by