views:

71

answers:

1
%# load a grayscale image
img = imread('coins.png');

%# display the image
figure
imshow(img,[]);

%# false-color
colormap('hot')

The above code is from here:

http://stackoverflow.com/questions/2592755/infrared-image-processing-in-matlab/2592793#2592793

But I don't understand how figure(What's the difference with/without it?) and colormap(How does it affect the already shown img?) work?

A: 

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.

False 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.

Colormap at the pixel level

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:

Jet

alt text

Bone

alt text

Jacob
What does `false color` mean?Also,can you elaborate how `colormap` works?
Mask
I've updated my answer
Jacob
How does `colormap` work in pixel level?
Mask
Updated in my answer
Jacob

related questions