Hello everyone,
I'm working on image/video processingin matlab. I've encountered a
problem, a simple one indeed, but troublesome, .. below I'm pasting a code
which is simply read an avi file and the I'm just converting the frames to
images and then I'm throwing away alternating rows, which reduces my image.
the problem is that it gets replicated .... why??
your helpwill be apprecaited ..thank you in advance
regards
Ahmad
close all;
clear all;
% file that we are gonna read
my_movie_info = aviinfo('redcup.avi');
my_movie_info.Filename;
my_movie_info.FileSize;
my_movie_info.FileModDate;
my_movie_info.NumFrames;
my_movie_info.FramesPerSecond;
my_movie_info.Width;
my_movie_info.Height;
my_movie_info.ImageType;
my_movie_info.VideoCompression;
my_movie_info.Quality;
my_movie_info.NumColormapEntries;
%*********************************************************************************************************************************
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%reading the avi file frame by
frame%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%declare array
M_Array=[];
% reading one frame at a time and storing it in to array
for i=1:my_movie_info.NumFrames;
mov=aviread('redcup.avi',i);
M_Array=[M_Array mov];
end
%*********************************************************************************************************************************
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Converting frames in to image for
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%processing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure;
R_Array=[];
for j=1:my_movie_info.NumFrames
map=[0 255];
%montage(image,map);%displays the images in new figure
[image,map]=frame2im(M_Array(j));
% mask=fspecial('log');
% I=imfilter(image,mask);
[r c]=size(image);
I=zeros(r/2,c);
p=1;
for m=1:2:r
for n=1:c
I(p,n)=image(m,n);
end
p=p+1;
end
%R_Array=[im2frame(I,map)];
%movie(R_Array)
montage(I,map)
end
Urgent help in matlab .. video processing
Started by ●May 31, 2006
Reply by ●June 2, 20062006-06-02
Thanks buddies,
the problem of reducing the frame size to half has been solved. now I'm getting the following problm, the reduced size of the frames cannot by converted back to movie frames (R_Array=[R_Array im2frame(I,map)]) ..
it gives the error that .... colormap cannot be empty .. and I don't know why is the (map variable empty) .... help will be appreciated
regards
Ahmad
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
R_Array=[];
for j=1:my_movie_info.NumFrames
%montage(image,map);%displays the images in new figure
[image,map]=frame2im(M_Array(j));
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%% reducing the width of the frames by half %%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I=zeros(my_movie_info.Height/2,my_movie_info.Width/2);
p=1;
for s=1:2:my_movie_info.Height
q=1;
for t=1:2:my_movie_info.Width
I(p,q)=image(s,t);
q=q+1;
end
p=p+1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% mask=fspecial('log');
% Im=imfilter(I,mask);
R_Array=[R_Array im2frame(image,map)];
%montage(I,map)
end
movie(R_Array)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
error: the colormap cannot be empty
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
the problem of reducing the frame size to half has been solved. now I'm getting the following problm, the reduced size of the frames cannot by converted back to movie frames (R_Array=[R_Array im2frame(I,map)]) ..
it gives the error that .... colormap cannot be empty .. and I don't know why is the (map variable empty) .... help will be appreciated
regards
Ahmad
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
R_Array=[];
for j=1:my_movie_info.NumFrames
%montage(image,map);%displays the images in new figure
[image,map]=frame2im(M_Array(j));
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %%%%%%%%%%%%% reducing the width of the frames by half %%%%%%%%%%%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I=zeros(my_movie_info.Height/2,my_movie_info.Width/2);
p=1;
for s=1:2:my_movie_info.Height
q=1;
for t=1:2:my_movie_info.Width
I(p,q)=image(s,t);
q=q+1;
end
p=p+1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% mask=fspecial('log');
% Im=imfilter(I,mask);
R_Array=[R_Array im2frame(image,map)];
%montage(I,map)
end
movie(R_Array)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
error: the colormap cannot be empty
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%