Overlay strain map on scan (colored plot over black and white plot)

I am attempting to make a graphic for a presentation in which I would like to throw a strain map over a black and white image used for texture correlation. I currently have been unable to create separate colorbars, resulting in a colored scan or a black and white strain map. I've attached an image of what I'm moreorless trying to capture but can't seem to produce.
The code below takes a 400x200 uint8 (for the BW image), and a 400x200 double (for the strain map). The values outside of the strain map in the structure are labeled as NaN. Likewise, transparency is currently set to 1s and 0s accordingly. I haven't included any of my own data here for a reference image or for running the code for privacy reasons.
f3 = figure( 3 );
%Exx strain map
image( dataIMG( :, :, frame ) ); hold on;
imagesc( exx_plot, 'AlphaData', transparency );
colormap( 'jet' );
caxis( [0 0.15] );
colorbar;

 채택된 답변

DGM
DGM 2022년 6월 9일
편집: DGM 2022년 6월 9일
Take the image you want to be grayscale and expand it to mxnx3 so that it isn't colormapped anymore:
For example,
% a grayscale image with some transparency
FG = imread('fg.png');
FGA = imread('fga.png');
opacity = 0.5;
% a grayscale image, but expanded
BG = imread('cameraman.tif');
BG = repmat(BG,[1 1 3]);
imshow(BG); hold on
hfg = imshow(FG);
hfg.AlphaData = FGA*opacity;
colormap(parula)
If you want both images to be colormapped independently, then you'll have to do it by overlaying two axes objects, since each axes can only have one colormap.

댓글 수: 1

Worked perfectly, thank you!
For anyone that may reference this post: FGA.png is simply a transparency matrix that labels the values to show on the plot and their opacity. For my purposes, I detected where my strain map fit onto the image and filled the borders with NaN values, and then set the strain map to 0.5 as suggested in this answer.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Red에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2022년 6월 9일

댓글:

2022년 6월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by