The errors happened in different version of matlab on the same code

1 Ansicht (letzte 30 Tage)
Stephen
Stephen am 6 Mai 2012
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 Kommentare
Wayne King
Wayne King am 6 Mai 2012
You should provide the error messages
Walter Roberson
Walter Roberson am 6 Mai 2012
Or if there is no error message, describe the difference between what you see and what you expect.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by