How to add transparency to a 2D colormap?

105 views (last 30 days)
Does anyone know, how to add transparency to 2D colormaps? I would like it to be overlaid over an image, so that both are visible. I will base the code on this one:
if true
%
data = rand(10,10);
minVal = min(min(data));
maxVal = max(max(data));
image(data,'CDataMapping','scaled');
cbar_labels = [0 0.12 0.2 0.3 0.5 0.6 0.75 0.8 1]; % user defined ranges
user_cmap = jet(8); % user defined colormap
customcmap(cbar_labels,user_cmap,[minVal maxVal])
end
Any hints will be appreciated!
Lukasz

Accepted Answer

Image Analyst
Image Analyst on 30 Mar 2015
  1 Comment
Lukasz Handzlik
Lukasz Handzlik on 1 Apr 2015
Thanks Image Analyst!
Your hints guided me towards the solution, which is:
if true
img=imread('picture.jpg');
imagesc(img);
hold on;
im=image(x,y,data,'CDataMapping','scaled');
alpha(im,0.5);
colorbar
end

Sign in to comment.

More Answers (0)

Categories

Find more on Colormaps in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!