Is the image "cameraman.tif" an indexed image?
[I , map] = imread('cameraman.tif')
size(map) % says an empty matrix
but changing the colormap changes it's color, why?
colormap(jet) % Changes the color of image.

 Akzeptierte Antwort

Guillaume
Guillaume am 8 Jan. 2015

0 Stimmen

Most likely, 'cameraman.tif' is just a greyscale image.
In any case, colormap works just as well for greyscale images, so is not any indication:
imshow(randi([0 255], 500, 500, 'uint8'));
colormap(summer);

2 Kommentare

'cameraman.tif' is a greyscale image, as shown by:
imfinfo 'cameraman.tif'
ans =
[...]
ColorType: 'grayscale'
[...]
adil erraad
adil erraad am 5 Apr. 2022
greattss

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Adam
Adam am 8 Jan. 2015

0 Stimmen

I would assume it is an indexed image in that case and if so you would fully expect changing the colourmap to change the image.

2 Kommentare

Gautam
Gautam am 8 Jan. 2015
Yeah , I agree to that and it changes color on changing the colormap. But how come the map is empty. Thanks for your reply
Because any grayscale image CAN be an indexed image. Like Guillaume says you can apply a colormap to a gray scale image because it will just use the gray level as an index. But with regular gray scale images, there is no colormap stored with the image. With indexed images there it, and needs to be, because the indexed image is essentially a color image with only 256 colors. If you look at an indexed image, the value is not a gray level but an index into a pseudocolor look up table. If you look at it with a gray(256) colormap, it may look like garbage. Look at the demo image canoe.tif, which is an indexed image:
[indexedImage, colorMap] = imread('canoe.tif');
imshow(indexedImage);
colorbar
It looks like garbage when viewed with a linear gray scale look up table because the values are not gray levels but are actually indexed into a row of a colormap. A value of 200 does not mean that the image is twice as bright as a pixel with value 100, like it would for a gray scale image (with no gamma). It simply means that the pixels with value 200 should use the 200th color (which may be blue or anything) while pixels with the value 100 should use the 100th color (which may be brown).
Now look at the same image when we use the colormap that was stored with it:
[indexedImage, colorMap] = imread('canoe.tif');
imshow(indexedImage);
colorbar
colormap(colorMap);
Let me know if that explains it better.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Images finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by