The errors happened in different version of matlab on the same code
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
As I posed before, http://www.mathworks.com/matlabcentral/answers/37417-how-to-get-the-value-of-a-certain-pixel-region-in-video-and-analyze-them runs well in matlab version R2009a.However, it goes wrong in version R2010. What was the problem? Thank you very much.
ps: original code is
%read the video
avi = aviread('sample.avi');
video = {avi.cdata};
pixels = double(cat(4,video{1:end}))/255;
nFrames = size(pixels,4)
%convert the video to gray scale
for f = 1:nFrames
pixel(:,:,f) = (rgb2gray(pixels(:,:,:,f)));
end
background=(pixel(:,:,1)+pixel(:,:,2)+pixel(:,:,3))/3; %get a background picture
%transfer the video to binary video and counting
for m = 2:1:nFrames
dif=(abs(pixel(:,:,m)-background));
bw = im2bw(dif, 0.2);
if (0==any(bw(:,314))) && (0~=any(bw(:,313)))
n=n+1;
disp(n)
end
end
2 Commenti
Walter Roberson
il 6 Mag 2012
Or if there is no error message, describe the difference between what you see and what you expect.
Risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!