Plotting ROI

4 次查看(过去 30 天)
ram m
ram m 2011-6-20
[EDIT: 20110620 16:25 CDT - reformat - WDR]
Hi
I am working with video on matlab.
I want to mention ROI(one or more) in the frames.
I get the starting and the ending macro block numbers and I make a rectangle and plot the ROI.
The problem with my code is, I am able to plot the box on the image if I have one ROI, but I am not able to mention two ROI, it gets updated to the new set:)
I want to plot two ROIs on a frame.
(I have the code I have written , can any one help em with that)
Thank you in advance.
clc;
close all;
clear all;
frames = yuv2mov('coastguard_dec.yuv',352,288,'420');
MB_map = importdata('roiOutput.dat');
PicWidthInMbs = 22;
ROI = 2;
I=vec2mat(MB_map,2);
[r1 c1]=size(frames);
disp(I);
[r c]=size(I);
for i=1: %framenumber
for j=1:ROI
top_left(j) = I(j,1);%+1;
bottom_right(j) = I(j,2);%+1;
fprintf('topleft=%d bottomright =%d \n',top_left(j),bottom_right(j));
yTopLeft(j) =
xTopLeft(j) =
yBottomRight(j) =
xBottomRight(j) =
xstart(j) = xTopLeft(j)*16+1;
ystart(j) = yTopLeft(j)*16+1;
yend(j) = yBottomRight(j)*16+16+1;
xend(j) = xBottomRight(j)*16+16+1;
frame1 = frames(i).cdata(:,:,:);
frame1(ystart(j),xstart(j):xend(j),:)=0;
frame1(yend(j),xstart(j):xend(j),:)=0;
frame1(ystart(j):yend(j),xstart(j),:)=0;
frame1(ystart(j):yend(j),xend(j),:)=0;
%hold on
figure(i)
hold on
imshow(frame1),title(i);
hold on
end
end

回答(1 个)

Walter Roberson
Walter Roberson 2011-6-20
Move the line
frame1 = frames(i).cdata(:,:,:);
to be between the "for i" and "for j" loops.
  3 个评论
Walter Roberson
Walter Roberson 2011-6-20
http://www.mathworks.com/help/techdoc/ref/videowriter.writevideo.html
VideoWriter is the recommended method these days, but if you have older software then you may need to use movie2avi()
ram m
ram m 2011-6-20
Thank you Sir

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Computer Vision with Simulink 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by