我想知道如何在 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 toimwrite
in your post is a MATLAB graphics handle to animage
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/