Image processing - TIFF images in Matlab in grayscale

image, image-processing, matlab, tiff

Solution

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:

Problem

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?

Original source