Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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 comentarios
Wayne King
Wayne King el 6 de Mayo de 2012
You should provide the error messages
Walter Roberson
Walter Roberson el 6 de Mayo de 2012
Or if there is no error message, describe the difference between what you see and what you expect.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by