Cameraman.tif is an indexed image?
조회 수: 70 (최근 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.
댓글 수: 0
채택된 답변
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
2015년 1월 8일
'cameraman.tif' is a greyscale image, as shown by:
imfinfo 'cameraman.tif'
ans =
[...]
ColorType: 'grayscale'
[...]
추가 답변 (1개)
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
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.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!