필터 지우기
필터 지우기

Multiple Colormaps, freezeColors won't work

조회 수: 15 (최근 30일)
JRJ
JRJ 2011년 6월 15일
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
Andrew Newell
Andrew Newell 2011년 6월 16일
Have you tried contacting the author of freezeColors?
JRJ
JRJ 2011년 6월 16일
I have not. I have actually discovered via a search that the reason freezeColors doesn't work is that I am overlaying things. freezeColors demands at least that the images be in seperate locations.

댓글을 달려면 로그인하십시오.

채택된 답변

Oliver Woodford
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
JRJ
JRJ 2011년 6월 16일
This has nearly worked!!! Thanks so much!
The only problem I am having with it is the automatic scaling real2rgb is doing. Basically, on most frames the bounds on my data are small and low, so a lot of random pixels are lighting up as red. However, on the more interesting frames, those pixels drop to blue and the pixels of interest light up as red. Is there any way to get more constant bounds on this?
Thanks,
Jed
Oliver Woodford
Oliver Woodford 2011년 6월 16일
You can specify the bounds used by real2rgb.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Walter Roberson
Walter Roberson 2011년 6월 16일
See this previous Question for a solution as to converting the raw data to scaled RGB.
  댓글 수: 1
JRJ
JRJ 2011년 6월 16일
Ah! got it!
The real solution came down to using real2rgb for the background, and ind2rgb for the foreground.
Thanks.

댓글을 달려면 로그인하십시오.


Alex Taylor
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
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
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 CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by