overlay 2 imagesc, where one is a section of the larger
3 次查看(过去 30 天)
显示 更早的评论
Hi there,
I'm trying to overlay 2 imagesc figures into 1. Both figures have the same length in x-axis, but different y-axis. One figure is a portion of the larger (see y axis on display). They also have different colomaps, one gray and the other jet.
Figure 1 comes from a matrix of 12502x40. Figure 2 comes from a matrix of 224x140.
y axis for figure 1 has a length of 12502. y axis for figure 2 has a length of 4034.
In addition, I would like to show only the colorbar of figure 2, at the bottom of the figure.
Here are the 2 images, and what I would like to achieve (done manually with paint).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/171947/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/171948/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/171949/image.jpeg)
I tried with imfuse command, but could not make it work as I need.
Hope someone out there can give me a hint.
Thanks in advance.
regards
0 个评论
回答(1 个)
Ahmet Cecen
2018-4-8
编辑:Ahmet Cecen
2018-4-8
This is kinda messy to do in MATLAB. See if you can decipher this:
%%Inputs
A = rand(100,100); %Big Image
B = 2*rand(45,32); %Small Image
BUpperLeftCorner = [20,15]; %Small Image Location
%%Make B Same Size by Padding
BB = padarray(B,BUpperLeftCorner-1,NaN,'pre');
BB = padarray(BB,size(A)-size(BB),NaN,'post');
%%Plot Overlay
figure;
% Behind Image
a1 = axes;
h1 = imagesc(a1,A); colormap(a1,'gray'); c1 = colorbar; axis image;
% Forward Image
a2 = axes;
h2 = imagesc(a2,BB); colormap(a2,'hot'); c2 = colorbar; axis image;
% Make Forward Image Transparent at Padding
alpha(h2, isfinite(BB)*1);
% Remove the Axes (the white canvas in a normal figure)
a1.Visible = 'off';
a2.Visible = 'off';
% Make background colorbar invisible.
% If you delete the colorbar, they will not align.
c1.Visible = 'off';
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!