function [drawRectangleImage] = drawRectangleFrame(image,windowLocation,windowSize)
[row,col] = size(image); % 输入图像尺寸
x = windowLocation(1);%矩形框位置坐标,其格式为[x,y]
y = windowLocation(2);
height = windowSize(1);%矩形框尺寸,其格式为[height,width],即[高度,宽度]
width = windowSize(2);
if((x<=row && y<=col)&&(height<=row && width<=col))
disp('矩形框合法!');
figure;imshow(image);
hold on
drawRectangleImage = rectangle('Position',[y-width,x-height,width+width,height+height],'LineWidth',4,'EdgeColor','r');
hold off
else
disp('矩形框不合法!');
end
end
%画圆
viscircles([20 30],10,'Color','g');%圆心坐标为(20,30),半径为10,轮廓颜色为绿色
axis([-10,60,-10,60]);
axis equal```
Matlab图像中画框框(公开代码)
于 2022-05-06 17:24:10 首次发布