【问题标题】:How to draw over a imagesc image in Matlab如何在 Matlab 中绘制图像
【发布时间】:2013-12-11 19:00:20
【问题描述】:

我有一个函数:

A = [5,16,18,4,9;
    9,10,14,3,18;
    2,7,9,11,21;
    3,7,2,19,22;
    4,9,10,13,8]

figure
colormap(gray)
imagesc(ones(15,15))
axis off
for t = 1:15
    for k = 1:15
        text(t, k, sprintf('%c', A(t,k) + 96))
    end
end

我想在一个位置和另一个位置之间画一条线,说从 (1,2) 到 (4,5) 我怎样才能做到这一点,我想我可以使用绘图或线条功能,但不知道如何使用它们。

【问题讨论】:

  • 请注意,您的索引与矩阵 A 的大小不匹配,我在下面的代码中相应地对其进行了调整。

标签: matlab plot line image-scaling


【解决方案1】:

如果我没有弄错:

A = [5,16,18,4,9;
    9,10,14,3,18;
    2,7,9,11,21;
    3,7,2,19,22;
    4,9,10,13,8]

figure
colormap(gray)
imagesc(ones(5,5))
axis off
for t = 1:5
    for k = 1:5
        text(t, k, sprintf('%c', A(t,k) + 96))
    end
end
hold on;
line([1 2], [4 5]);

结果:

【讨论】:

    猜你喜欢
    • 2016-03-26
    • 2017-08-11
    • 1970-01-01
    • 1970-01-01
    • 2014-04-13
    • 1970-01-01
    • 1970-01-01
    • 2010-12-06
    • 1970-01-01
    相关资源
    最近更新 更多