MATLAB: Multiple Colormaps, freezeColors won’t work

alphacolormapcolormapsfreezecolorsimageimagesimagescmultipletransparency

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

Best Answer

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