Two colormaps in the same plot
이전 댓글 표시
Hi,
I am superimposing two images, here, I would like to use different colormap for first and second images. For e.g. jet for image 1 and hot for image 2..
I have tried this, however, at the end, both the images got the colromap defined for image 2. If somebody has gone through this kind of situtaion, please help me with this..
채택된 답변
추가 답변 (1개)
Steve Eddins
2020년 11월 9일
You can't display images with two different colormaps within the same axes. As a workaround, you could convert both images from indexed to rgb, like this:
rgb1 = ind2rgb(X1,jet(256));
rgb2 = ind2rgb(X2,hot(256));
These two images can then be displayed or superimposed together. RGB image display is independent from the colormap.
댓글 수: 11
Turbulence Analysis
2020년 11월 9일
Steve Eddins
2020년 11월 9일
Scale and then round your X1 and X2 matrices so that they contain integers in the range 1 to 256.
Turbulence Analysis
2020년 11월 9일
Steve Eddins
2020년 11월 9일
Can you clarify? Do you need the image CData values to be the same as the original data values? If so, for what purpose?
Turbulence Analysis
2020년 11월 9일
Steve Eddins
2020년 11월 9일
You can use a separate variable to store the scaled values and use that separate variable to display the image. The original values are retained in the original variable.
Turbulence Analysis
2020년 11월 9일
Steve Eddins
2020년 11월 9일
Why? Why is that a constraint for you?
Turbulence Analysis
2020년 11월 9일
Steve Eddins
2020년 11월 9일
Can you expand a little bit more in your replies? I don't think I'm getting enough information to be able suggest a workaround. Please say more about exactly what you are doing or displaying with the images so that it makes a difference what the CData values are.
Turbulence Analysis
2020년 11월 10일
카테고리
도움말 센터 및 File Exchange에서 Color and Styling에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!