如何在 Matlab 中使用 set(h,...) 更新图像位置?
How to update an image position using set(h,...) in Matlab?
我在 Matlab 中绘制了一张图:
pic=imread('mypic.bmp');
figure(1)
h=image([1 1.2],fliplr([1 1.2],pic)
现在我想把这张图移动到图中的其他位置,方法是this question:
for i=2:3
indices=[i i+.2];
set(h,'?1',indices,'?2',fliplr(indices))
end
除了 ?1
和 ?2
我还需要填写什么?在提到的问题中,考虑 plot
命令时,他们使用 XData
和 YData
.
图像对象(无论是使用 imshow
、imagesc
还是 image
创建)也 具有 XData
and YData
properties.
xdata = get(h, 'XData');
ydata = get(h, 'YData');
它们指定图像数据的 x 和 y 范围。您可以像 plot
对象一样更改它们。
for k = 2:3
indices = [k, k+0.2];
set(h, 'XData', indices, 'YData', fliplr(indices));
% Be sure to make it so the axes can display it
set(gca, 'XLim', indices, 'Ylim', indices);
end
我在 Matlab 中绘制了一张图:
pic=imread('mypic.bmp');
figure(1)
h=image([1 1.2],fliplr([1 1.2],pic)
现在我想把这张图移动到图中的其他位置,方法是this question:
for i=2:3
indices=[i i+.2];
set(h,'?1',indices,'?2',fliplr(indices))
end
除了 ?1
和 ?2
我还需要填写什么?在提到的问题中,考虑 plot
命令时,他们使用 XData
和 YData
.
图像对象(无论是使用 imshow
、imagesc
还是 image
创建)也 具有 XData
and YData
properties.
xdata = get(h, 'XData');
ydata = get(h, 'YData');
它们指定图像数据的 x 和 y 范围。您可以像 plot
对象一样更改它们。
for k = 2:3
indices = [k, k+0.2];
set(h, 'XData', indices, 'YData', fliplr(indices));
% Be sure to make it so the axes can display it
set(gca, 'XLim', indices, 'Ylim', indices);
end