首页 > 解决方案 > 用两个不同的句柄叠加两个图像,以便以后可以单独设置“CData”

问题描述

我必须处理需要重叠的图像处理,并且它需要能够在set(h1, 'CData' data)以后处理循环内的性能问题。但是,此要求使其难以相互重叠。

data1 = rand(100, 100);
data1 = rand(100, 100);

figure;
h1 = imagesc(data1);
colormap('hot')
h1.AlphaData = 0.5;

figure;
h2 = imagesc(data2);
colormap('cool')
h2.AlphaData = 0.5;

for 1=1:200
    data1 = rand(100, 100);
    set(h1, 'CData', data1);
    data2 = rand(100, 100);
    set(h2, 'CData', data2);

    % How do I overlap these two images here? If possible the most efficient way possible since the data will be a large matrix in real-life.

    drawnow;
end

知道如何实现这一目标吗?提前致谢。

编辑:预期的输出将与此类似,其中两个图像以半透明度相互叠加(或不降低透明度也可以,只要两个地图/图像在叠加图像中易于区分):

第一张图片

第二张图片

叠加

取自数学论坛

每次如果要放入循环中,链接引用都会创建一个新的图像对象,我试图避免这种情况。这就是为什么我决定CData接近。

标签: matlab

解决方案


推荐阅读