I am trying to do some operations on color video in MATLAB however, I am facing 2 problems:
I am getting an error while converting color video to grayscale
Try it this way. This should do the trick. The code is self-explanatory.
vid = VideoReader('xylophone.mpg');
numImgs = get(vid, 'NumberOfFrames');
frames = read(vid);
obj=VideoWriter('somefile.avi');
open(obj);
for i=1:numImgs
movie(i).cdata=rgb2gray(frames(:,:,:,i));
movie(i).colormap=gray;
end
writeVideo(obj,movie);
close(obj);