Overlay two images in one axes?

3 ビュー (過去 30 日間)
xi
xi 2020 年 1 月 21 日
回答済み: Image Analyst 2020 年 1 月 22 日
I have two images of the same object, but with different resolutions (and sizes).
I want to show the high resolution image in grey scale as the background and the low resolution image in parula colormap (for example) in the foreground, and add some adjustable transparency so that both can be visualized.
I realize that, I first need to do image registration of the two and then, I can overlay them using
imshowpair(img1,ref1,img2,ref2), where, ref1 and ref2 are image references. obtained using imref2d.
But how can I plot them in two different color scales of my own selection, in one axes? and I can freely adjust the properties of two image objects?
  4 件のコメント
xi
xi 2020 年 1 月 21 日
Thanks very much for your comment. Both images are Grey scale type, no RGB data. I just need to show them in two different colormaps. See sample images I1 and I2 in attached.
I want I2 to be grey scale in the background, I1 on top of I2 with some transparency, arbitrary colormap, and its CDATA can be updated.
xi
xi 2020 年 1 月 21 日
Here's a workaround solution I just figured out, but I'm not happy with two images sharing the same colorbar.
Because the colormap is specified by the axes property, and there's only one sharing axis.
It would be ideal to show one colorbar on the left and another on the right, and they can be individually controlled.
-------------------------------------------------------------
img1=I1/max(max(I1)); %normalize to [0,1]
img2=-I2/max(max(I2)); %normalize to [-1,0]
img2=padarray(img2,[1830,6880],'pre'); %shift
figure
ref1=imref2d(size(img1),0.05,0.05); %rescale to mm
ref2=imref2d(size(img2),0.0048,0.0048); %%rescale to mm
h2=imshow(img2,ref2);
hold on
h1=imshow(img1,ref1);
ax=gca;
ax.CLim=[-1,1]; %set color limit
ax.Colormap=[1-gray;[[0:1/63:1]',zeros(64,2)]]; %set colormap
colorbar
ax.XLim=[34,45];
ax.YLim=[9,20];
h1.AlphaData=0.7;

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2020 年 1 月 21 日
RGB = repmat(I2,1,1,3);
h2 = image([0 1], [0 1], RGB);
hold on
h1 = image([0 1], [0 1], I1, 'alphadata', 0.8);
colormap(parula);
hold off
and you can set the CData property of h1 as needed.
I2 will not appear grayscale, but that is because you are overlaying RGB on top of it.

Image Analyst
Image Analyst 2020 年 1 月 22 日
With newer versions of MATLAB, try imoverlay().

カテゴリ

Help Center および File ExchangeRed についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by