Plotting ROI
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
[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
0 Commenti
Risposte (1)
Walter Roberson
il 20 Giu 2011
Move the line
frame1 = frames(i).cdata(:,:,:);
to be between the "for i" and "for j" loops.
3 Commenti
Walter Roberson
il 20 Giu 2011
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()
Vedere anche
Categorie
Scopri di più su Computer Vision with Simulink in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!