Summary of the invention
The present invention overcomes the shortcoming of prior art, the moving target detecting method of a kind of combination neighbor frame difference method and mixed Gauss model has been proposed, advantage in conjunction with two kinds of methods, both alleviated the empty problem that neighbor frame difference method produces, also eliminate background object and transferred suddenly " shadow " problem producing after moving object to, can carry out accurate, real-time moving object detection to detection zone.
A moving target detecting method for combination neighbor frame difference method and mixed Gauss model, comprises the following steps:
1) obtain image sequence, comprise present frame and former frame image;
2) to present frame, utilize improved neighbor frame difference method to be divided into interim moving region and interim background area;
3) to 2) in 2 regions producing with mixed Gauss model, mate respectively, according to matching result, be divided into again different regions;
4) Gauss model in zones of different carries out different renewals;
5) according to 3) in the region that produces determine last motion target area;
Described step 2) comprising:
A) present frame and former frame are subtracted each other and taken absolute value, establish f
k(x, y) and f
k+1(x, y) represents respectively the pixel value of coordinate points (x, y) in former frame and present frame, calculates their difference result d
x(x, y):
d
k(x,y)=|f
k+1(x,y)-f
k(x,y)|
B) the Grad Grad of the pixel of calculating present frame in M * M window
k(x, y), work as M=5:
C) Grad of more adjacent two frame same coordinate position pixels, it is larger to calculate the weight coefficient of frame when poor just larger that gradient differs, and makes r represent gradient factor, Fd
k(x, y) represents to introduce the frame difference of gradient factor, calculates Fd
k(x, y):
Fd
k(x,y)=d
k(x,y)×r
The relevant system of gradient difference of the value of r and the pixel of adjacent two frame same coordinate, it is larger that gradient differs, and the value of r is also larger;
D) by Fd
k(x, y) sorts with the frame difference data of front J frame, using middle value as the poor Fd of new frame
k(x, y);
E) the poor Fd of new frame
k(x, y) and threshold value T compare, if be greater than threshold value, this point are designated as to 1, if be less than threshold value, are designated as 0;
F) the later bianry image of thresholding is carried out to connected component processing, after processing by connected component, image is divided into interim moving region a
fg and interim background area a
bg, a wherein
fgcomprise moving object and its interior void region that neighbor frame difference method calculates;
Described step 3) comprises:
G) in mixed Gauss model, comprise N Gauss model, for i Gauss model, in t its parameter of the moment, comprise: average value mu
i,t, variance
with weight w
i,t, parameter is initialization when the first two field picture;
H) pixel that is Xt for pixel value, judges that it with the condition that certain Gauss model mates is:
|X
t-μ
i,t-1|<2.5σ
i,t-1
If meet this condition, this Gauss model mates with pixel, if do not met, do not match, Gauss model according to
size order sort, the Gauss model of B model as a setting before rank; To a
fgand a
bgarea pixel point carries out respectively mixed Gauss model coupling, according to matching result, image is divided into 4 regions: 1. a
fgthe region a inside matching
fgm, 2. a
fgthe region a inside not matching
fgu, 3. a
bgthe region a inside matching
bgm, 4. a
bgthe region a inside not matching
bgu;
Described step 4) comprises:
I) a
fgmthe renewal of Gauss model in region:
w
i,t=(1-α)w
i,t-1+αM
i,t
μ
i,t=(1-ρ)μ
i,t-1+M
i,tρX
t+ρμ
i,t-1(1-M
i,t)
Wherein, α is parameter turnover rate, gets larger value (for example 0.1) here, w
i,t, μ
i,twith
be respectively i Gauss model in t weight, mean value and variance constantly,
m
i,tvalue and i Gauss model at t, whether mate relevantly constantly with pixel, if mated, get 1, do not mate and get 0;
J)a
fgugauss model in region does not upgrade, and does not set up new Gauss model yet;
K)a
bgmgauss model update method and i in region) in similar, parameter turnover rate α gets more moderate value that different is (for example 0.01);
L) a
bguin region, except the Gauss model of weight minimum, all the other are all according to i) in formula upgrade, parameter turnover rate α value is in 0.01 left and right; A newly-built Gauss model substitutes the model of weight minimum, and the parameter of newly-built Gauss model is set to: average μ
tget current pixel value X
t, variances sigma
tget a smaller value, weight w
tafter value makes more greatly normalization, this new established model rank is higher;
Described step 5) comprises:
M) consider f) in the motor image vegetarian refreshments and a that calculate
fguregion, determines final motion target area again after mark connected component.
Advantage of the present invention is: for neighbor frame difference method, increased gradient ratio and medium filtering, given prominence to moving object boundary and anti-noise jamming ability.By the testing result in conjunction with neighbor frame difference method and mixed Gauss model, image is divided into 4 regions, the mixed Gauss model in each region is adopted to different parameter turnover rates.Compare with common mixed Gauss model, reduced the interference of moving target to background model, for object motion with static between situation about changing also there is good adaptability.The judgement of final moving object is also the testing result in conjunction with two kinds of methods, has both alleviated the empty problem that neighbor frame difference method produces, and has also eliminated background object and has transferred suddenly " shadow " problem producing after moving object to.
Embodiment
The combination neighbor frame difference method that the present invention proposes and the moving target detecting method of mixed Gauss model, it implements process flow diagram as shown in Figure 1, by adjacent 2 two field pictures that obtain, calculate the poor and gradient difference of frames, gradient difference result be incorporated into frame poor in, frame difference datas present frame is poor and front 4 frames sort, middle value is poor as new frame, and frame is poor becomes 0 or 12 system numbers through threshold value after relatively.The bianry image that 2 system numbers represent is processed through connected component, be divided into foreground area and background area, to these 2 regions, use mixed Gauss model to mate respectively, according to matching result, image subdivision, be 4 regions, according to different regions, Gauss model is taked to different update methods, in conjunction with neighbor frame difference method and mixed Gauss model and re-start connected component and process and to draw motion target area.
Below in conjunction with Figure of description, the inventive method is elaborated.
Fig. 1 is the implementing procedure figure of the inventive method.First obtain 2 adjacent two field pictures, " adjacent " herein can be both continuous adjacent 2 frames 2 two field pictures of certain frame number that can be also middle intervals.This determines according to actual situation, if video speed is too fast or be not very high to the requirement of monitoring, can get successive frame and obtains a frame every several frames.
Present frame and former frame are subtracted each other and taken absolute value, establish f
k(x, y) and f
k+1(x, y) represents respectively the pixel value of coordinate points (x, y) in former frame and present frame, calculates their difference result d
x(x, y):
d
k(x,y)=|f
k+1(x,y)-f
k(x,y)|
The Grad Grad of the pixel that to calculate coordinate in k two field picture be (x, y) in M * M window
k(x, y), work as M=5:
If the gradient difference of the pixel of adjacent 2 frame same coordinate is larger, show that this pixel is more likely motor point.So gradient difference is larger, the weight r of gradient difference is larger, and the method for definite r a kind of is as follows:
Grad wherein
mingrad
kand Grad
k-1in minimum value, Grad
maxgrad
kand Grad
k-1in maximal value.
Make Fd
k(x, y) represents to introduce the frame difference of gradient factor, calculates Fd
k(x, y):
Fd
k(x,y)=d
k(x,y)×r
Introduce gradient difference and can be good at outstanding moving object border and internal edge, outstanding motor image vegetarian refreshments, processes and provides convenience for connected component below.But because have the noise of randomness in the image collecting, gradient factor also can be amplified the impact of noise.In order to eliminate the impact of noise, also need the poor medium filtering that passes through of frame.The poor Fd of present frame
k(x, y) sorts with the frame difference data of front J frame, using middle value output as the poor Fd of new frame
k(x, y), the value of J is determined on a case-by-case basis, for example, be 5.
Result after threshold process is still more coarse, in order to obtain profile and the size of more accurate moving object, also needs the view data after thresholding to carry out the mark of connected region.Employing is that 8 neighborhoods are asked connected region, if current point is 1, it is 0 that the value of revising this point makes it, and 8 picture elements around it are searched for, if having value around in 8 points is 1 point, the value of revising these points is 0 and record these points, and then centered by these points, searches for respectively.Repeat said process, until be all 0.The connected component that mark is crossed is all to represent by the form of rectangle frame, and what in rectangle frame, represent is the poor pixel that is greater than threshold value of frame.Although it is overlapping that connected component does not exist, the rectangle frame of mark but likely exists overlapping, as shown in Figure 2, thus just need to overlapping connected component be merged, to obtain moving object shape more accurately.After processing by connected component, image is divided into interim moving region a
fgwith interim background area a
bg, a wherein
fgcomprise moving object and its interior void region that neighbor frame difference method calculates.
To interim moving region a
fgwith interim background area a
bgwith mixed Gauss model, mate respectively, according to matching result, be divided into again different regions.In mixed Gauss model, the value of the number N of model is generally 5~7, can adjust according to the memory capacity of computing machine and arithmetic capability.For i Gauss model, in t its parameter of the moment, comprise: average value mu
i,t, variance
with weight w
i,t, parameter is initialization when the first two field picture; During initialization mixed Gauss model parameter, mean value is got the respective pixel point value X of the first two field picture
1, variance is got a larger value as far as possible.
For pixel value, be X
tpixel, judge that it with the condition that certain Gauss model mates is:
|X
t-μ
i,t-1|<2.5σ
i,t-1
If meet this condition, this Gauss model mates with pixel, if do not met, do not match, Gauss model according to
size order sort, the Gauss model of B model as a setting before rank, the value standard of B is:
at least before the weight w of B Gauss model
i,tsum is greater than T, and the value of T is between 0~1.If T more greatly, has a plurality of Gaussian distribution model to describe background, this is better for such jamming pattern treatment effect such as the tree of rocking, but also likely occurs moving object to be used as the mistake of background.If T is smaller, only have a Gaussian distribution model to describe background.
To a
fgand a
bgarea pixel point carries out respectively mixed Gauss model coupling, according to matching result, image is divided into 4 regions: 1. a
fgthe region a inside matching
fgm, 2. a
fgthe region a inside not matching
fgu, 3. a
bgthe region a inside matching
bgm, 4. a
bgthe region a inside not matching
bgu.
Gauss model in zones of different carries out different renewals:
A
fgmthe renewal of Gauss model in region:
w
i,t=(1-α)w
i,t-1+αM
i,t
μ
i,t=(1-ρ)μ
i,t-1+M
i,tρX
t+ρμ
i,t-1(1-M
i,t)
Wherein, α is parameter turnover rate, gets larger value (for example 0.1) here, w
i,t, μ
i,twith
be respectively i Gauss model in t weight, mean value and variance constantly,
m
i,tvalue and i Gauss model at t, whether mate relevantly constantly with pixel, if mated, get 1, do not mate and get 0;
A
fgugauss model in region does not upgrade, and does not set up new Gauss model yet;
A
bgmgauss model update method and a in region
fgmsimilar in region, parameter turnover rate α gets more moderate value that different is (for example 0.01);
A
bguin region, except the Gauss model of weight minimum, all the other are all according to a
fgmformula in region upgrades, and parameter turnover rate α value is in 0.01 left and right; A newly-built Gauss model substitutes the model of weight minimum, and the parameter of newly-built Gauss model is set to: average μ
tget current pixel value X
t, variances sigma
tget a smaller value, after weight wt value makes more greatly normalization, this new established model rank is higher.
Although mixture gaussian modelling can have certain adaptability to the variation of environmental background, but the turnover rate of its parameter is fixed, if parameter turnover rate is too little, context update is too slow, the unexpected variation response time for background can be slow, and if parameter turnover rate is too fast, just lose the ability that it describes complex background.So in this algorithm, parameter turnover rate α can adjust dynamically according to the result of neighbor frame difference method: region a
fgmthe Gauss model of interior pixel is given larger parameter turnover rate (0.1); Region a
fguthe result of interior two kinds of methods is more consistent, in order to reduce the impact of moving target on background, does not build new Gaussian distribution; Region a
bgminterior Gauss model parameter turnover rate adopts more moderate turnover rate (0.01), can reduce the impact of noise and also can carry out suitable renewal to background; Region a
bguinterior pixel need to re-construct a Gauss model, and distributes a higher weight w
t(as 0.3) and smaller variances sigma
t.
Finally, consider motor point and moving object and a that neighbor frame difference method calculates
fguregion, determines final motion target area again after mark connected component.
The superiority of the inventive method result is described with an example below.Fig. 3 adopts 5 test video sequence of Wallflower as test source, adopts the moving object detection result of the wherein frame drawing after the inventive method processing, and compares with benchmark result.Benchmark result is manual obtaining, expression moving object that can be more accurate.These 5 test videos represent respectively different problem typeses, can reflect the comprehensive treatment capability of the inventive method.In video Bootstrap, there are a plurality of objects in motion always.In video Camouflage, a people comes into computer and has covered computer, and people's clothes color and computer color very approaching.In video LightSwitch, brightness within doors has larger several times variation, and chair can become motion from static.In video MovedObject, have a people to enter in room, after mobile phone and chair, leave again, the object being moved also can incorporate in background.In video TimeOfDay, room brightness brightens suddenly, and has a people to come in to be sitting on sofa.The empty problem (seeing the testing result in video Camouflage) that the inventive method can reasonable alleviation neighbor frame difference method as can be seen from Figure 3, also can solve (seeing the testing result in video LightSwitch and MovedObject) preferably for the unexpected transfer problem of background and moving region.The detection error number comparative result of the inventive method and additive method is as shown in table 1, wherein False neg represents is in benchmark result, to mark motor point and mistake that testing result does not mark, False pos represents be in benchmark result, be not motor point detected result be designated as the mistake in motor point.The detection error rate of the inventive method is low compared with additive method as seen from Table 1, can comparatively accurately detect moving object.
Table 1
Obviously, do not departing under the prerequisite of true spirit of the present invention and scope, the present invention described here can have many variations.Therefore, all changes that it will be apparent to those skilled in the art that, within all should being included in the scope that these claims contain.The present invention's scope required for protection is only limited by described claims.