Code covered by the BSD License  

Highlights from

2.0 | 2 ratings Rate this file 24 Downloads (last 30 days) File Size: 1.78 KB File ID: #30264 Version: 1.0
image thumbnail



David Legland (view profile)


Converts an array of double (2D or 3D) to an RGB image using specified colormap

| Watch this File

File Information

Computes the min and max values within the input array, convert to 256 values, and apply a colormap to produce a color image (RGB).

It is possible to specifies the range of values to consider, as well as the background color (used for NaN values).

% Display a default matrix
subplot(1, 2, 1);
imshow(peaks(128), []);
title('as double')
% display the coresponding RGB image
subplot(1, 2, 2); imshow(double2rgb(peaks(128), jet, [-8 8]));
title('as RGB');

MATLAB release MATLAB 7.9 (R2009b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (5)
06 Nov 2011 Sepideh

Sepideh (view profile)

Great code! I needed to obtain the corresponding color for an array in gray scale and it perfectly worked for me.

Comment only
06 Nov 2011 Sepideh

Sepideh (view profile)

06 Nov 2011 Sepideh

Sepideh (view profile)

06 Feb 2011 David Legland

David Legland (view profile)

Hi Oliver,

the two features that make this file a little bit different are:
* it works for 2D or 3D images
* it is possible to specify a color for "background", i.e. NaN values.

But I think these options could be easily added to other files you mentioned.


Comment only
02 Feb 2011 Oliver Woodford

From the help text it seems like this does exactly the same thing as several other functions available here, e.g. mat2im, real2rgb, etc. What are the benefits?

Comment only

Contact us