Reputation: 34207
Consider:
%# load a grayscale image
img = imread('coins.png');
%# display the image
figure
imshow(img,[]);
%# false-color
colormap('hot')
The above code is from here:
Infrared image processing in Matlab
But I don't understand how figure
(what's the difference with/without it?) and colormap
(how does it affect the already shown image?) work?
Upvotes: 0
Views: 1523
Reputation: 34601
figure
is not required, imshow
just displays img
on it. If a figure
hadn't been opened, imshow
would've created a new one.
The colormap
colors the intensities of the image. The hot
map colors values in increasing intensity with black, red, yellow, and white-hot. Another popular colormap is jet
which has a number of interesting colors.
So the matrix you want to see has intensities which can have any range of values. For better visualization, the intensities are displayed in a range of colors or a set of false colors. Normally, a grayscale image will display an image is shades of grey, where white is maximum and black is minimum. False color is an extension of that concept with several colors in between (like jet
) and an effect of metal being heated in hot
.
Suppose you have a matrix with pixel values ranging from [cmin xmax]
. Now, normalize the values so that the range is [0,1]. Also, suppose you have a color map, such that a range of colors are mapped to some values from 0 to 1 (e.g. 0.5 is mapped to RGB(100,200,100))- then you get the false color mapping by finding the closest intensity in the map and display the corresponding color.
More on colormap in the MATLAB documentation. I've included some picture from that link here:
(source: mathworks.com)
alt text http://www.mathworks.com/access/helpdesk/help/techdoc/ref/bone_spine.gif
Upvotes: 1