Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Motion estimation vs. background subtraction
Date: Thu, 13 Mar 2008 13:28:01 +0000 (UTC)
Organization: STFC Rutherford Appleton Laboratory
Lines: 65
Message-ID: <frba51$nt5$1@fred.mathworks.com>
References: <fr8o5t$m76$1@fred.mathworks.com> <fr8rvq$rfs$1@fred.mathworks.com> <frb7ii$fpa$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1205414881 24485 172.30.248.35 (13 Mar 2008 13:28:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 13 Mar 2008 13:28:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 968489
Xref: news.mathworks.com comp.soft-sys.matlab:457028



"Torvald Helmer" <torvald.helmer@mathworks.com> wrote in 
message <frb7ii$fpa$1@fred.mathworks.com>...
> Thanks for the reply!
> 
> I have normalized the rgb like this:
> Rn = R(x,y) / sum(R(x,y)) G(x,y)) B(x,y));
> 
> where Rn is the normalized value for Red, two similar 
> operation for Green and Blue.
> 
> 
> I plan to just extract the first 10 frames and calculate 
> the mean pixel value from these frames, and create a new 
> image for which will be set as background. Is this good 
> enough? What do you use the std. deviation for in this 
case?
> 
> You say I should choose a confidence level, for example 
> three times larger than sigma. Is the sigma the same as  
> the absolute difference between to pixels?
> 
> 
> Thanks, Helmer.

Your equation for normalizing RGB is usually pretty good, a 
better one - but takes longer to compute is

REDNESS = Red/(sqrt(Red^2 + Green^2 + Blue^2))

Of course similar equations hold for GREENNESS and BLUENESS

Sigma(x,y) is the standard deviation derived from your 
empty background image phase.

10 frames seems enough to start the process with - however 
I would be tempted to continue the accumulation of 
background statistics using any frame that didn't contain a 
moving object - just a personal quirk perhaps. Obviously 
the more frames you accumulate the better the statistics.

During operation time you pull in a frame. If you subtract 
this frame from your mean background image, you can then 
test if the pixel difference is statistically meaningful - 
or whether it can be explained by the ambient noise level 
at that pixel location. If, for example, the difference 
value is smaller than say 3 times the standard deviation it 
is unsafe to conclude that the difference is significant, 
and you should declare this a null difference. If on the 
other hand the difference is greater than the 3 sigma 
threshold, then the difference can be safely declared as a 
real effect, and treated as a change in the image. This 
technique has the advantage that in regions where the 
background colour does vary considerably between blank 
frames, then the standard deviation is a lot higher, so to 
be identified as a real change, the variation must be that 
much greater than in a relatively stable zone.

From memory, the equations for continuously updating the 
estimate for the mean and standard deviation of an 
indefinite sequence of numbers has been outlined on this 
forum several times.

Hope that helps

Dave Robinson