tags:

views:

38

answers:

2
+3  Q: 

colormap in matlab

For a colormap how do you accentuate the brightness of some of the dimmer features?

+3  A: 

You can use the BRIGHTEN function to brighten the entire colormap, thus brightening the dimmer features as well:

brighten(0.5);  %# Brightens the current colormap

%# OR...

newMap = brighten(oldMap,0.5);  %# Brighten the colormap in variable oldMap
colormap(newMap);               %# Update the current colormap to newMap

If you want to brighten only the dimmer features (i.e. just part of the colormap), you have to first decide how to classify what counts as a "dimmer" feature. ;)

gnovice
+1 another interesting function is CONTRAST: given an image, it create a grayscale colormap that enhances the contrast http://www.mathworks.com/access/helpdesk/help/techdoc/ref/contrast.html
Amro
+2  A: 

If you have a grayscale colormap, the grayvalues map linearly to the intensities. In order to enhance dim features, you want the low intensities to be mapped onto a larger range of grayvalues than the high intensities. In other words, you stretch the low intensities and compress the high intensities. This can be done by adjusting the gamma of the colormap. Of course you can do a gamma correction for RGB colormaps as well.

If you have the image processing toolbox, the Matlab command for this is IMADJUST, which you use like this:

newColormap = imadjust(oldColormap,[low_in; high_in],[low_out; high_out],gamma);

The new colormap maps the values in the range low_in/high_in to the range low_out/high_out - so you most likely want to use minimum/maximum of the colormap - and gamma is what you want to set to >1.

An alternative, quick way to emphasize dim features is to display the square root (or, for a more pronounced effect, the logarithm) of your image.

imshow(sqrt(img),[])
Jonas
+1: IMADJUST is a good option, assuming of course that you have the Image Processing Toolbox. ;)
gnovice
@gnovice: thanks, I clarified the solution - though I personally tend to use the square root or log for emphasis. It's a lot quicker and requires less fiddling.
Jonas

related questions