在另一个图上使用来自一个图的颜色条

Use a colorbar coming from one plot on an other plot

我加载了两张图片,想通过观察来比较它们。图像是动态的,因此固定颜色条在这里不起作用。

所以我显示了两张图片,第一张用 caxis auto 初始化了一个颜色条。现在我想在下一张图中重复使用找到的 caxis,我该怎么做?

figure;imshow(firstimage);
caxis auto;
c = colorbar;




figure;
imshow(secondimage);
colorbar(c) %does not work but shows what I want to have

我相信你可以 运行 像这样:

figure;
imshow(firstimage);
caxis auto;
c = colorbar;
cmin = c.Limits(1);
cmax = c.Limits(2);
figure;
imshow(secondimage);
colorbar
caxis([cmin cmax]);