File Exchange

image thumbnail

double2rgb

version 1.0 (1.78 KB) by

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

21 Downloads

Updated

View License

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

Example:
% 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');

Comments and Ratings (6)

Hamid Hasani

Sepideh

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

Sepideh

Sepideh

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.

Regards

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?

MATLAB Release
MATLAB 7.9 (R2009b)
Acknowledgements

Inspired: Easy Plot EEG Brain Network Matlab

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video