splitting a video into frames using image function after using mmreader to read video file...

조회 수: 14 (최근 30일)
*I wasn't being able to bring an avi file into the workspace, so I brought the video into the MATLAB file and played it using implay...then I want to split it into its individual frames..
According to the solution by Walter Roberson on
n=size('cell.avi')
n =
1 8
for frame= 1:n
('cell.avi')(frame)=getframe;
|
But I get_ :Error: Unbalanced or unexpected parenthesis or bracket.
_
image function!!*
Now I want the individual frames as individual images, so I put: image(('cell.avi')(1).cdata) image(('cell.avi')(1).cdata) | *Error: Unbalanced or unexpected parenthesis or bracket. * *What is wrong? I've been able to load the movie, but now I can't split it into the frames using

채택된 답변

Image Analyst
Image Analyst 2011년 10월 18일
Look at the help for mmreader() . . . again . . . more carefully this time. You'll see read() does not take a string, it take the movie object, and the number of the frame you want to read. So instead of
video = read('cell.avi');
you'd want
% Read from ii from movie M
oneFrame = read(M, ii);
  댓글 수: 7
Yagnaseni Roy
Yagnaseni Roy 2011년 10월 19일
Btw,
referring to M = mmreader('cell.avi');
N = M.NumberOfFrames;
for ii = 1:N
image(M.read(ii));
pause(0.1);
end
HOW WOULD I CALL FOR AN INDIVIDUAL FRAME...SUPPOSE FRAME 5?? i TRIED image(M.read(5));
...IS THIS NOT SUPPOSED TO WORK?
Yagnaseni Roy
Yagnaseni Roy 2011년 10월 19일
Doing this, I seem to get the last frame each time...even when I change to image(M.read(6));image(M.read(20));....they all look the same.

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

추가 답변 (2개)

Sean de Wolski
Sean de Wolski 2011년 10월 17일
n=size('cell.avi')
will say that n = [1 8] since 'cell.avi' is an eight letter long string (row vector of characters).
Here's probably closer to what you want:
M = aviread('rhinos.avi');
for ii = 1:length(M)
image(M(ii).cdata)
pause(.1)
end
  댓글 수: 10
Yagnaseni Roy
Yagnaseni Roy 2011년 10월 17일
Apparently, 'cell.avi' is a 8 character string and none of the functions are working on it..
Walter Roberson
Walter Roberson 2011년 10월 18일
M = mmreader('cell.avi');
N = M.NumberOfFrames;
for ii = 1:N
image(M.read(ii));
pause(0.1);
end

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


Dimple Chawla
Dimple Chawla 2012년 4월 17일
hey, it really helped me too, actually i'm working on similar project like calculating difference of object property in frame such as 1st and the 20th or the last frame. Can u help on this.?? I will deftly appreciate your effort. Thanks reply asap

Community Treasure Hunt

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

Start Hunting!

Translated by