Summarize what you have mastered so far, and write it down for the time being (don't bother writing formulas).
Gaussian background modeling general steps:
1, using the first frame image initialization parameters
Including, initial expectation, initial standard deviation, threshold coefficient and learning rate or update rate;
2, foreground detection
The new read-in image is inferior to the expected value, and the result is compared with the threshold to detect the foreground target.
3, update parameters
Including, expectation, standard deviation;
4. Repeat the 2,3 step until the end of the image sequence
The background model can be expressed as expected.
The MATLAB program is as follows, where the initial parameters are referenced by other articles.
% Gaussian background model
clear all;
Close all;
CLC;
% Read Files
= Dir (fullfile (' Directory \ ', ' *.bmp '));
Lengthfiles = Length (Files);
% is initialized by the first frame parameter
img0 = Imread (strcat (' Directory \ ', Files (1). name));
U = Double (Rgb2gray (IMG0)); % initial expected
std =; % initial standard deviation
var = std.^2; % Initial variance
Lamda = 2.5*1.2; % comparison coefficient
alpha = 0.05; % update rate
fg_result = u;
% foreground detection
for i=2:lengthfiles
imgx = Imread (strcat (' Directory \ ', Files (i). name));
IMGX = Rgb2gray (IMGX);
img = double (IMGX);
Fg_result = ABS (img-u) >=lamda*std; % foreground extract
% update parameter
u = (1-alpha) *u+alpha*img;
var = (1-alpha) *var+alpha* (img-u). ^2;
std = sqrt (var);
% showing results
subplot (121), imshow (IMGX);
Subplot (122), Imshow (fg_result,[]);
GetFrame;
End
% background model
figure,imshow (u,[]);
Learning rate or update rate will have a great impact on the final background model, the standard deviation will have an impact on the foreground extraction, how to adjust the parameters is a problem.
Always feel that some places do not want to understand, but do not know exactly where.