在 MATLAB GUI 中使用按钮保存的图像无法显示在目标文件夹中

Image saved using pushbutton in MATLAB GUI cannot be displayed in destination folder

无法显示我从 GUI 保存到目标文件夹的图像。该文件在文件夹中可用,但显示的图像只是白色 canvas 而不是我 saved.Any 想知道为什么会这样的图像?

您可能在正确的代码中做错了。添加 "hold on" 可能会解决您的问题。

imshow(frameReference,'Border', 'tight',handles.figure1); hold on
plot(centroidsFiltered(:,2),centroidsFiltered(:,1),'g','LineWidth',1.5);
print(handles.figure1,'-r0','-dpng', 'figure.png');

这个例子运行良好。 您也可以使用 saveas 函数。

由于您使用的是 GUI,当您打印图形时,您需要声明图形的正确处理程序。比方说 handles.figure1。您只需要将其用作参考即可。