필터 지우기
필터 지우기

Plot rectangle boxes on image using MATLAB

조회 수: 15 (최근 30일)
akhil sambar
akhil sambar 2016년 5월 26일
댓글: Nut 2016년 5월 26일
Here I am developed some code for plotting boxes on image but I am getting boxes on different image. All the boxes should be in same image. Please help me in this. Thank in advance.
<<
<<
>>
>>
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
  댓글 수: 2
KSSV
KSSV 2016년 5월 26일
you want to plot boxes on a given jpg/png image?
akhil sambar
akhil sambar 2016년 5월 26일
yes

댓글을 달려면 로그인하십시오.

채택된 답변

Nut
Nut 2016년 5월 26일
편집: Nut 2016년 5월 26일
Hi,
what if you substitute the line:
figure, imshow(J);
with these lines?
if i == 1
figure, imshow(J);
end
Is it a proper working for you?
  댓글 수: 2
akhil sambar
akhil sambar 2016년 5월 26일
yeah, its working. Thank you RoBo :)
Nut
Nut 2016년 5월 26일
Of nothing.
However, I forgot to tell you in the previous answer, but... a more elegant solution should be to move the lines:
figure, imshow(J);
hold on;
before the "for" cycle. It should be also more efficient, I think.
Goodbye

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by