[image, map] = imread('filename.tif') returns empty color map? Image file is a 32-bit z-stack.
3 views (last 30 days)
Show older comments
Hi: I'm trying to read a 98-slice 32-bit z-stack into MATLAB. It is the result of a distance transformation with a LUT applied. As you can see, if I call imfinfo, it shows that each slice has a color map. So why is it that when I call for example, [z1, map] = imread('filename.tif', 1) I get an empty ([]) map? Also, if I am using the Tiff class to write my result again, as a single 32-bit float type .tif file, is there a way I can save the LUT as well? I have attached one slice of the z-stack if anyone wants to take a closer look. Thanks!

0 Comments
Answers (1)
Image Analyst
on 12 Jun 2017
I don't understand why a floating point image would have a colormap stored with it. How can the floating point number be used as a row index into your 256 element colormap? How did you generate "ans", your structure. Was it by calling imfinfo() with the same filename as using imread(), so they're both reading the very same file? Can you attach that file? Have you tried using the Tiff class instead of imread() to read in the images?
5 Comments
Image Analyst
on 12 Jun 2017
You might need to use the 'index' keyword:
[z1, map] = imread('filename.tif', 'index', 1);
whos map
if isempty(map)
warndlg('Map is empty');
else
helpdlg('Map has stuff in it');
end
I think might come down to a colormap not making sense for a floating point image. Why do you think one is applicable?
You might have to talk to tech support and send them your image for them to figure out if it's resolvable or not. Otherwise save your image as uint8 if you want a colormap. Or else just don't worry about the colormap.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
