MATLAB: Extracting frames using mmreader and calculate and substract mean from data

meanmmreader

hello all, i am using mmreader to input video,
i want to extract all Y frames of video object and calculate their mean and finally subtract their mean from the data.
so that y frames will be mean zero.
plz help.
thanks….

Best Answer

xyloObj = mmreader('xylophone.mpg');
%Make a 4d rgb volume
V = zeros(xyloObj.Height,xyloObj.width,3,xyloObj.NumberOfFrames,'uint8');
for ii = 1:size(V,4)
V(:,:,:,ii) = read(xyloObj,ii);
end
%subtract mean (V zero mean)
V = double(V); %must be double (or single)
Vzmean = bsxfun(@minus,V,mean(mean(V,1),2));
Related Question