File Exchange

image thumbnail

scalar2colormap

version 1.0.0.0 (9.08 KB) by Viljami Sairanen
Grayscale image into monopolar or bipolar RGBA image with colorbar.

0 Downloads

Updated 11 Jul 2017

View License

Function scalar2colormap is designed to transform 2D scalar image into a monopolar or bipolar RGBA image. Colormaps can be defined independently for negative, zero, and positive scalar values. Colormap can be imposed on a background image with a chosen transparency and cropped with an additional mask image. Colormaps are linear by default but function supports for non-linear mapping as well to further enhance polar differences. Optional output gives object handles for figure, axes, images, and colorbar for final tuning (titles, fonts, labels etc.) of the image.

Comments and Ratings (2)

Thank you Grigorii for pointing this out: scalar2colormap assumes that OVERLAY is a double array. To avoid this error just call the function like

[H_FIG, H_AX, H_BG, H_OVERLAY, H_COLORBAR] = scalar2colormap(double(OVERLAY))

I'll add a check for different datatypes in next version.

Error using .*
Integers can only be combined with integers of the same class, or scalar doubles.

Error in linspace (line 30)
y = d1 + (0:n1).*(d2 - d1)/n1;

Error in scalar2colormap (line 204)
steps = linspace(min(OVERLAY(:)), max(OVERLAY(:)), size(cmap,1));

Updates

1.0.0.0

Example image

MATLAB Release Compatibility
Created with R2016b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: bluewhitered, Red Blue Colormap, imoverlay