How to use images from a video?

1 view (last 30 days)
Ravi
Ravi on 22 Jan 2014
Commented: Ravi on 22 Jan 2014
Can any one help me with coding of a 2d DCT(4x) for a video? please
  • *Method1:* *
movie=aviread('f.avi');
movie(1)%%displays first frame's data%%
frame_nums=[1 2 3 4];
movie2=aviread('f.avi',frame_nums);%%reads the indexed frames%%
imshow(movie(1).cdata)
file_info=aviinfo('f.avi')
file_info.NumFrames%%gives us no. of frames in video%%
image_data=uint8(zeros(file_info.Height,file_info.Width,3,file_info.NumFrames));
for k=1:file_info.NumFrames
image_data(:,:,:,k)=movie(:,:,:,k).cdata;%%error showing in this line%%
end
  • * Method2: * *
workingDir=tempname;
mkdir(workingDir);
mkdir(workingDir,'images');
video=VideoReader('f.avi');
for ii = 1:4
img = read(video,ii);
% Write out to a JPEG file (img1.jpg, img2.jpg, etc.)
imwrite(img,fullfile(workingDir,'images',sprintf('img%d.jpg',ii)));
end
img= im2double(img)
T=dctmtx(8);
dct2=T*img*T';
B=blockproc(img,[8 8],dct2);%%error in this line%%
mask = [1 1 1 1 0 0 0 0
1 1 1 0 0 0 0 0
1 1 0 0 0 0 0 0
1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0];

Answers (1)

Walter Roberson
Walter Roberson on 22 Jan 2014
image_data(:,:,:,k)=movie(k).cdata;
  1 Comment
Ravi
Ravi on 22 Jan 2014
Assignment has fewer non-singleton rhs dimensions than non-singleton subscripts
still error persists..Can any one help me?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!