Effacer les filtres
Effacer les filtres

How can I write an image mat array (class:double) of values ranging from -182000 to 137081 into gray/color image file using 'imwrite' function? Because using the below code misses so many pixels in the final image.

1 vue (au cours des 30 derniers jours)
load CT;
colormap(jet);
figure, imagesc(sum_CT);
set(gca,'XTickLabel',[],'YTickLabel',[]);
imwrite(sum_CT,'CT.bmp', 'bmp');

Réponse acceptée

Walter Roberson
Walter Roberson le 3 Juin 2013
Have a look at the imwrite() documentation:
If the input array is of class double, and the image is a grayscale or RGB color image, imwrite assumes the dynamic range is [0,1] and automatically scales the data by 255 before writing it to the file as 8-bit values.
Any negative double values you try to write will thus end up clipped at 0.
If you are trying to write the equivalent of the imagesc() then you need to do the scaling yourself before you imwrite() the result.
  1 commentaire
VENKATESAN
VENKATESAN le 3 Juin 2013
Thanks for your answer... yes it happens... only I can see the 0 and 255 values in the resulting images. But, how can we use the scaling range(imagesc) to write the image with negative values too.. Thank you

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by