matlab - imshow 显示与 imwrite 不同的输出

标签 matlab image-processing matlab-figure

我想知道如何在 matlab 中保存由 imshow 创建的图像。下面的代码使用 imshow 函数并指定了 min 和 max 参数 - 如何将其直接应用于图像本身,而不是仅仅指定 Matlab 来显示它?

maxBlur=3;

a = imshow(fDmap,[0 maxBlur]);

imwrite(a, 'img.png');

写入文件会产生与通过 imshow 显示的不同的输出。

有人可以建议如何将 imshow 的输出保存为图像吗?

最佳答案

指定 imwrite 的强度上限和下限(类似于您对 imshow 所做的操作),您将需要使用 mat2gray 的第二个输入在使用 imwrite 保存图像之前调整图像的对比度。

imwrite(mat2gray(fDmap, [0 maxBlur]), 'img.png');

如果您确实想要使用 imshow 看到的图像,您可以使用 saveas截取屏幕截图。这可能会比以前的方法分辨率更低,并且还会包含图像周围的空白。

imshow(fDmap, [0 maxBlur]);
saveas(gcf, 'img.png'); 

NOTE: The a variable that you passed to imwrite in your post is a MATLAB graphics handle to an image object that is used to manipulate the rendered image. imwrite expects image data in matrix form not as a graphics handle.

关于matlab - imshow 显示与 imwrite 不同的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36039081/

相关文章:

matlab - 如何制作饼图以便我可以单击任何切片?

image - 如何输出层叠图像或堆叠图像

matlab - 在时间(日期)轴上绘制数据

c - 函数的隐式声明 'min'

java - 使用 Java 命令 Matlab

algorithm - 图像抓取和索引算法(通过图像的颜色)和文本搜索给出相应的图像

c# - 动态更改图像编码?

arrays - Matlab数组的动态切片

matlab - 将 2 个图像合并为一个平面图像

image - 图片中的笔划检测算法检测直线和曲线