在 imshow() 中更新图像?

Update image in imshow()?

我正在尝试随着时间的推移显示图像,因为它是由函数转换的。我使用 imshow() 来显示我的图像。

如果我使用代码,

im = zeros(y,x);

for n=...
   im = im + myFunction(...);
   imshow(im)
end

然后,图像的每次迭代都正确显示。问题是显示的数字非常小。如果我尝试在脚本 运行 时调整图形,则一旦到达 for 循环的下一次迭代,图像就会重置为其原始大小。

我希望能够调整显示大小并使其保持在屏幕上我想要的大小和位置。

imshow() 的文档指出,

'Parent' — Parent axes of image object
Axes object | UIAxes object
Parent axes of image object, specified as the comma-separated pair consisting of 'Parent' and an Axes object or a UIAxes object. Use the 'Parent' name-value argument to build a UI that gives you control of the Figure and Axes properties.

网上其他与此问题相关的问题都指向使用set axes。下面是我尝试使用轴的尝试。

figure
ha = axes('units','normalized','position',[0 0 1 1]);
im = zeros(y,x);
imshow(im, 'Parent', ha);

for n=...
    im = im + myFunction(...);
    imshow(im, 'Parent', ha);
end

此代码无效。由于某种原因,该图直到 for 循环完成后才显示。尽管最初的 imshow 调用甚至在 for 循环开始之前。

如有任何帮助,我们将不胜感激。

如果您的图像不会将迭代更改为迭代,则假设大小,一种选择是设置 imshow 返回的图形图像对象的 CData 属性。

 hIm = imshow(im, 'Parent', ha);
 
 for n=...
      im = im + myFunction(...);
      hIm.CData = im;
      drawnow limitrate
 end