matlab如何将第一张图的作图痕迹(比如画矩形框),保留到后面的图像上(比如在1.jpg上的矩形框,还出现在2/3/4../n.jpg的图像上)

matlab如何将第一张图的作图痕迹(比如画矩形框),保留到后面的图像上(比如在1.jpg上的矩形框,还出现在2/3/4../n.jpg的图像上)
问题相关代码,请勿粘贴截图
运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果

使用 hold on

hold on命令使用示例:依次在极坐标中绘制心形线、圆、偏心圆于一张图中,

clc,clear,close all;
theta=-pi:0.001:pi;
r=1+sin(theta);  %心形线方程,“桃p股”朝下
polar(theta,r,'r');
hold on
r1 = 1.*ones(size(theta));  %极坐标画圆
polar(theta,r1,'b--');
r2 = 2.*0.5.*sin(theta);  %极坐标画偏心圆
polar(theta,r2,'g--');
r2 = -2.*0.5.*sin(theta);
polar(theta,r2,'g--');

img

对比subplot分子图效果:

img

如果以上不是你预想实现的效果,请回复具体需求。

clc,clear;
str='D:\study\Work\LSD\image';
strl='D:\study\Work\LSD\rec1';
for i=1:2
a = imread('D:\study\Work\LSD\image\1.jpg');
figure(1),imshow(a);%显示图像
end
c=zeros(2,4);
%画ROI
for i=1:2
b=imrect;
h=getPosition(b);%在图片上画roi区域
c(i,:)=h;
row=round(h(2));
col=round(h(1));
high=round(h(4));
width=round(h(3));
out_roi=a(row:row+high,col:col+width,: );
d(i,:)=out_roi(i,:);
end
for i=2:5
a = imread([str,num2str(i),'.jpg']);%从路径读取图片
figure(2),imshow(a); %显示图像
rec1=rectangle('position',[c(1,1),c(1,2),c(1,3),c(1,4)]);
rec2=rectangle('position',[c(2,1),c(2,2),c(2,3),c(2,4)]);
imwrite(out_roi,[strl num2str(i) '.jpg' ]);
end