matlab输出图像并在图像上框出物体

一张 M*N 大小的图片,在图像上画出一个width*height并且左上角坐标为(x,y)的矩形框,可用如下代码:

res = insertShape(img,'Rectangle',[x y width height]);
%在图像img上画一个width*height的矩形框,矩形框左上角坐标为(x,y)

举个栗子,把下图中的小狗框出来:

图片像素为352*240,小狗左上角坐标为(36,81)
用一个长120宽80的矩形框把狗狗框出来 

 

img = imread('img.jpg');
res = insertShape(img,'Rectangle',[36 81 120 80]);
imshow(res)

运行结果为:

posted @ 2019-10-25 19:45  昨夜昙花  阅读(107)  评论(0)    收藏  举报