How can I accurately display the colors of this indexed TIF image in MATLAB?

8 views (last 30 days)
I have a collection of images which are TIFs. I am attaching the output of iminfo for one of the files in question (iminfo.txt).
The problem I am trying to solve is that Windows image viewer displays the files differently than MATLAB, as shown HERE. I want the images to look as they do in the windows image viewer, and I will be incorporating them into a GUI later.
The above image is the result of this code:
overallImage = imread('trace7_ave.tif');
show_TIF_GUI, image(overallImage)
axis image
I have also tried this code, in which the tif displays as a completely black square (which is the same thing that happens if I try to open the tif in GIMP; I am sure this is no coincidence.) This is modeled after an example in the help file for imread:
[X,cmap] = imread('trace7_ave.tif');
imshow(X,cmap);
And finally, I have tried the following code, which displays in greyscale:
Y = imread('trace7_ave.tif');
imshow(Y);
I also understand that image and imshow are different commands, but you will see I have tried variations of both above. My guess is that I need to use imshow so I can handle the color mapping correctly, but I am unsure how to do that.
  1 Comment
Eric Yokie
Eric Yokie on 17 Jun 2020
The answer was in the MATLAB documentation; it was a matter or choosing the correct methodology.
The solution was to model my code after the following:
t = Tiff('example.tif','r');
Read the image data and the associated alpha matting.
[RGB,A] = readRGBAImage(t);
Display the image.
imshow(RGB)

Sign in to comment.

Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!