Gaussian background Modeling Simple program

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.