Black image getting saved while using imsave
4 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Adam
2015-3-13
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 个评论
Adam
2015-3-16
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!