在使用MATLAB过程中,我们往往需要再图像上使用plot()函数画一些东西,然后将其显示的figure中,但要将plot()处理后的图像保存的本地,有一定难度。以下介绍两种方法:
将figure进行保存
我们使用figure显示图像,然后使用hold on 和hold off命令,使用plot函数在图像上绘制自己的需求
img = imread('a.png');
figure;imshow(img); % binary image
[m,n] = find(image==1);
[xrect,yrect] = minboundrect(m,n);
hold on
plot(xrect,yrect,'b-');
hold off
frame = getframe(gcf); % 获得当前图窗
im = frame2im(frame); % 将图窗转换为图片
imwrite(im,'modified_a.png');
直接保存图像
img = imread('a.png');
figure;imshow(img); % binary image
[m,n] = find(image==1);
[xrect,yrect] = minboundrect(m,n);
hold on
plot(xrect,yrect,'b-');
hold off
frame = getframe; % 获得当前坐标区的内容
im = frame.cdata; % 获得图像数据
imwrite(im,'modified_a.png');
最后
以上就是开心小丸子最近收集整理的关于matlab——使用plot()对图像进行处理之后将图像保存在本地将figure进行保存直接保存图像的全部内容,更多相关matlab——使用plot()对图像进行处理之后将图像保存在本地将figure进行保存直接保存图像内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复