How to use images from a video?
1 view (last 30 days)
Show older comments
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];
0 Comments
Answers (1)
See Also
Categories
Find more on Computer Vision with Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!