Image processing - TIFF images in Matlab in grayscale

user3089045 picture user3089045 · Feb 18, 2014 · Viewed 8.5k times · Source

In Matlab, when I use

imshow('trees.tif')

it displays an RGB image, but when I use these two functions

I=imread('trees.tif')
imshow(I)

it displays a gray scale image, and it's still the exact same image.

This only happens with TIFF images, because when I use it for a JPEG image like so:

I=imread('flower.jpg')
imshow(I)

it displays an RGB image, and it's the same thing as imshow('flower.jpg').

Can anyone please explain why the use of imread/imshow on TIFF images displays them in gray scale?

Answer

chappjc picture chappjc · Feb 18, 2014

Load the color map too:

[I,cmap] = imread('trees.tif');

Display it with the map:

imshow(I,cmap)

Convert it to RGB:

Irgb = ind2rgb(I,cmap)

So you can display and manipulate it without the colormap:

imshow(Irgb)
imagesc(Irgb)
% etc.

Eye candy:

enter image description here enter image description here enter image description here