Cameraman.tif is an indexed image?

36 次查看(过去 30 天)
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.

采纳的回答

Guillaume
Guillaume 2015-1-8
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 个评论
Guillaume
Guillaume 2015-1-8
'cameraman.tif' is a greyscale image, as shown by:
imfinfo 'cameraman.tif'
ans =
[...]
ColorType: 'grayscale'
[...]

请先登录,再进行评论。

更多回答(1 个)

Adam
Adam 2015-1-8
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 个评论
Gautam
Gautam 2015-1-8
Yeah , I agree to that and it changes color on changing the colormap. But how come the map is empty. Thanks for your reply
Image Analyst
Image Analyst 2015-1-8
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by