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

2 ビュー (過去 30 日間)
Stephen
Stephen 2012 年 5 月 6 日
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 件のコメント
Wayne King
Wayne King 2012 年 5 月 6 日
You should provide the error messages
Walter Roberson
Walter Roberson 2012 年 5 月 6 日
Or if there is no error message, describe the difference between what you see and what you expect.

サインインしてコメントする。

回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by