Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image processing - TIFF images in Matlab in grayscale

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?

like image 690
user3089045 Avatar asked Feb 18 '14 21:02

user3089045


1 Answers

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 hereenter image description hereenter image description here

like image 166
chappjc Avatar answered Sep 28 '22 10:09

chappjc