本文介绍了在Matlab中在图像上绘制矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图弄清楚如何在Matlab中的图像上绘制矩形.
I am trying to figure out how to draw rectangles on an image in Matlab.
在图像上绘制矩形之后,我想保存更改.
Once the rectangles are drawn on the image I would like to save the changes.
提前谢谢!
推荐答案
使用 getframe
img = imread('cameraman.tif');
fh = figure;
imshow( img, 'border', 'tight' ); %//show your image
hold on;
rectangle('Position', [50 70 30 60] ); %// draw rectangle on image
frm = getframe( fh ); %// get the image+rectangle
imwrite( frm.cdata, 'savedFileName.png' ); %// save to file
有关更多选项,请参见 矩形
关于绘制矩形.矩形的'Position'
参数的格式为 [from_x from_y width高度]
,并且以像素为单位.
See rectanlge
for more options on drawing rectangles. The 'Position'
argument for rectangle is in format [from_x from_y width height]
and is given in units of pixels.
这篇关于在Matlab中在图像上绘制矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!