1
这里我开发了一些用于绘制图像框的代码,但是我在不同的图像上获取了
框。所有的盒子应该在相同的图像。 请帮我。使用MATLAB在图像上绘制矩形框
video = VideoReader('parking video1.mp4');
I = read(video,1);
J = read(video,200);
a=104; b=73;
c=104; d=515;
count=0;count1=0;count2=0;
total=10;
for i=1:5
im1=imcrop(I,[a,b,283, 448]);
im3=imcrop(J, [a,b,283, 448]);
Background1 =abs(im1 - im3);
grayImage1 = rgb2gray(Background1);
% Convert to gray level
thresholdLevel1 = graythresh(grayImage1);
% Get threshold.
binaryImage1 = im2bw(grayImage1, thresholdLevel1);
% Do the binarization
binaryImage1 = bwareaopen(binaryImage1,1000);
ak=bwarea(binaryImage1);
figure, imshow(J);
hold on;
if ak>0
rectangle('Position',[a,b,283, 448],'Edgecolor', 'r');
else
rectangle('Position',[a,b,283, 448],'Edgecolor', 'g');
end
a=a+280;
end
或者在for循环之前打开数字并使用循环中的句柄。像'fig1 = figure;'然后'为... figure(fig1)... end'。 – shamalaia
它不起作用 –
说实话,你的问题并没有很好的定义。这是不明显的你想要做什么。我认为你的问题是,带有红色矩形的图像出现在一个数字窗口中,绿色的图像出现在另一个数字窗口中。那是对的吗? – kkuilla