Chapter 2 Moving target detection based on background difference and MATLAB implementation

Moving target detection based on background difference

MATLAB implementation

  1. Significance of the subject

Moving object detection is a branch of image processing and computer vision, which has great significance in theory and practice, and has been concerned by scholars at home and abroad for a long time. In practice, using cameras to monitor a specific area is a meticulous and continuous process that can be done by humans, but it is unreliable and expensive for humans to perform such long-term and boring routine monitoring , so it is very necessary to introduce motion monitoring. The background subtraction method is the most commonly used method in motion detection at present, and it is a technology to detect the motion area by using the difference between the current image and the background image. It can generally provide the most complete feature data, but it is particularly sensitive to changes in dynamic scenes, such as lighting and interference from external irrelevant events. In this algorithm, one or the average of several images in the background is first selected as the background image, and then the background image is subtracted from the current frame of the subsequent sequence image to perform background elimination. If the obtained number of pixels is greater than a certain threshold, it is determined that there is a moving object in the monitored scene, thereby obtaining a moving target.





  1. Common methods of moving target detection

2.1 Manual background method

The manual background method requires people to observe the background image, select a certain frame image as the background image, and then analyze and calculate other objects with the selected background image

. However, this background extraction method consumes a lot of manpower and material resources, and in many cases, it is difficult to obtain a background image, because in a video, the background may shake, and different images have different exposures, and objects in the background may It has always existed, so the error of the manual background method is relatively large. However, for the vehicle monitoring system of the expressway, since the camera is fixed, the image background can be obtained when there is no vehicle, so that the application of vehicle detection and vehicle flow statistics is more widely used, and of course it is not limited to the road vehicle detection system. It can also be applied to community access control systems, etc.






2.2 Statistical median method

Considering that there are few moving objects, that is, in the continuous multi-frame images, the background pixel values ​​account for the main part, that is, the background image changes slowly during this period of time, then we can take the median value of the sequence of images , taking the median image can be considered as the background image

2.3 Arithmetic mean method

Using the arithmetic mean method to extract the background image is a relatively simple background calculation method, that is, to add all the images, and then take the average method, which is the background image. Why can the algorithm average method be used for background extraction? The main consideration is that the background information accounts for the main part of the image. Different frames of images contain image background information. The addition and averaging method is used to weaken the moving target and highlight the background information, so N frames can be continuously read. image, and then carry out algorithmic averaging method for background extraction. Similarly, such an algorithmic averaging method can also weaken the background white noise points of the image. Therefore, the arithmetic mean method has the function of smoothing the image.






v2-fb58cc0086ebc20d5e84d85bea367f31_b.jpg

v2-a381f611e3f8e573ee47a716e9c2cf0b_b.jpg



(a) 1st frame image (b) 30th frame image


v2-3c6de3e6ac90524f9133e72969f538a0_b.jpg


(c) The 60th frame image



After calculating the arithmetic mean value for 60 consecutive frames, the MATLAB program is as follows:



clc,clear,close all % clear the screen, clear the work area, close the window

warning off % disable warning

feature jit off % speed up code execution

im1 = imread('1.jpg'); im1 = im2double(im1); % load the image and convert it to double

type

im2 = imread('30.jpg'); im2 = im2double(im2); % load the image and convert it to double

type

im3 = imread('60.jpg'); im3 = im2double(im3); % load the image and convert it to double

type

im4 = imread('80.jpg'); im4 = im2double(im4); % load the image and convert it to double

type

im5 = (im1+im2+im3+im4)/4; % average operation

do

figure,imshow(im5,[])





v2-6cb786c2ca80c49e4baa5043f445e3cb_b.jpg



Figure 2- 2 Background image extracted by arithmetic method






2.4 Inter-frame difference method

The inter-frame difference method is similar to the background difference method, that is, the difference between the connected frame images is used to realize the extraction of the moving target. The selection of the connected frames can be customized by the user, for example, choose 1 frame apart, 2 frames apart, ..., N frames images etc. Using the frame difference method can also ignore the influence of the image background, and can adapt to the moving target detection of complex images, but using the frame difference method for moving target extraction, the extraction error is relatively large, and the user needs to supplement it with other image processing methods. Accurate extraction of moving targets. Therefore, it can be concluded that improper selection of connected frames is not conducive to the extraction of image moving objects, and the user needs to continuously debug to determine a reasonable choice of the number of frames apart.


Dix , y  

Iix ,

y   Ii 1  x , y


Mx , y   1, DiT

i 0, D T

i













v2-b03856e383a859cb5c411e988f540ced_b.jpg

v2-110a9b4f9209f8bc0207f9d0809d0898_b.jpg



(f) Binarized image after difference (i) Binarized image after difference

Guess you like

Origin blog.csdn.net/TuTu998/article/details/120177091