function [BG_promedio]=Calcular_BG_promedio(video,ini,fin)
    BG_promedio=zeros(video.Height,video.Width); %Escala de Grises
    numframes=fin-ini+1;
    for i=ini:fin
        frame_RGB=read(video,i);%escala RGB
        frame_Gray=double(rgb2gray(frame_RGB));%double y gray
        BG_promedio=BG_promedio+frame_Gray;
    
    %     imagesc(frame_Gray);
    %     colormap gray;
    %     pause(0.001);
    end
    BG_promedio=BG_promedio/numframes;
end