Cameraman.tif is an indexed image?
144 views (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Guillaume
on 8 Jan 2015
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 Comments
Guillaume
on 8 Jan 2015
'cameraman.tif' is a greyscale image, as shown by:
imfinfo 'cameraman.tif'
ans =
[...]
ColorType: 'grayscale'
[...]
More Answers (1)
Adam
on 8 Jan 2015
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 Comments
Image Analyst
on 8 Jan 2015
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.
See Also
Categories
Find more on Blue in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!