Multiple Colormaps, freezeColors won't work
8 次查看(过去 30 天)
显示 更早的评论
Hi,
I am trying to use one image as a background, and one image in the foreground with transparency. I have acomplished this, but I need to use colormap(gray) for the background and colormap(jet) for the foreground. These images are arrays of data in an unknown range.
Currently, the code works except that the background is not in grayscale.
I have tried freezeColors, and it does not work.
Thanks
hold on
imagesc(handles.bg,'Parent',movie_scrn)
colormap(gray)
hold off
colormap(jet)
hold on
tmpImg = image(handles.cmosData(:,:,frame),'Parent',movie_scrn);
alphaMap = handles.cmosData(:,:,frame) >= handles.minVisible;
set(tmpImg, 'AlphaData', alphaMap);
2 个评论
采纳的回答
Oliver Woodford
2011-6-16
Use real2rgb to convert your data matrices to images, and do the alpha matting in software by combining them as follows:
G = real2rgb(handles.bg, 'gray');
J = real2rgb(handles.cmosData(:,:,frame), 'jet');
A = real2rgb(handles.cmosData(:,:,frame) >= handles.minVisible, 'gray');
I = J .* A + G .* (1 - A);
image(I, 'Parent', movie_scrn);
2 个评论
更多回答(2 个)
Alex Taylor
2011-6-16
Hi,
The issue here is that in the MATLAB graphics system, the 'colormap' is a property of the figure, meaning that you can only display grayscale images with one colormap per figure.
The workaround is to use the MATLAB function ind2gray to convert your grayscale images to RGB images. You will then be able to display both RGB image in the same figure with your desired coloring.
2 个评论
Walter Roberson
2011-6-16
ind2rgb is not appropriate for this situation, at least not by itself. JRJ has a pure data matrix that is getting converted to a plot via imagesc(), which is doing data range translation and rescaling.
Alex Taylor
2011-6-16
Walter, yes, you are right. I was focusing my attention on the "why isn't the grayscale colormap being honored" part of the question. I wasn't attempting to provide a complete solution.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Orange 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!