Black image getting saved while using imsave

4 vues (au cours des 30 derniers jours)
Mathews John
Mathews John le 13 Mar 2015
Commenté : Adam le 16 Mar 2015
Hey,
I am trying to save a part of a 16 bit image using imsave as a TIFF file. When I save the image (using imsave()), it is showing up as a black image on my computer's image viewer (Windows Photo Viewer). Initially I thought that Photo Viewer might not be supporting 16 bit images, but that doesn't make much sense because I can see the full image before I import it into MATLAB for cropping.
When I import the saved TIFF file to MATLAB, I can use imagesc() to view the image but not imshow(image, [0 2^16-1]). When I checked the maximum value of the imported image, it's only around 957. So, I think what's going on is that since the pixel values are just between 0 and 957, and the image viewer has 2^16 levels, the image isn't showing up properly. Is there anyway I can save the image such that it shows up on my viewer?
Thanks in advance.
Thank you.

Réponses (1)

Adam
Adam le 13 Mar 2015
Just scale it up to use the full 16-bit range before you save it.
i.e. multiply by 65535/957
but replacing the hard-coded numbers with something calculated for reusablility.
  2 commentaires
Mathews John
Mathews John le 16 Mar 2015
Thank you.
The scaling, as it was supposed to, worked. I do not understand what you meant by 'replacing the hard-coded numbers with something calculated for reusablility' Could you give an example?
Adam
Adam le 16 Mar 2015
Well, obviously 957 is not going to be correct for every image you may use so you should replace that code with code that takes its value from the maximum of your image.
Likewise the 65535 is only correct for a 16-bit image. If you may be handling images of other data types then this value should be taken appropriately for the data type.

Connectez-vous pour commenter.

Catégories

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

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by