vid = videoinput('winvideo',1);
set(vid.source,'AnalogVideoFormat','pal_i');
frames = 2;
foto = getsnapshot(vid);
foto = uint16(foto);
res = size(foto); 
whos;
res[1]
res[2]
res[3]
for i=1:res[2]
for j=1:res[1]
for n=2:frames
foto(i,j,:,1)=foto(i,j,:,1)+foto(i,j,:,n);
end
foto(i,j,:,1)=foto(i,j,:,1)/frames;
end
end
image(foto(:,:,:,1))