I am looking for a method to classify pixels into three groups: (1) Pixels which does not change their intensity much in general (the slight changes may be due to noise only), (2) Pixels which change their intensity very slowly, in general monotonically and gradually, and (3) Pixels which change their intensity drastically over a certain threshold.

I tried using the Running Gaussian Average Method, such as checking how many standard deviations the current pixel is away from the running mean. The pixel is classified as group (1) when the result is very small, as group (3) when the result is very large, and (2) otherwise. But it does not seem to work very well, especially for group (2) because by definition, this group contains pixels which change their intensity moderately instead.

I expect I may need to build 2 or more models, because background subtraction methods normally result in classifying the pixels into 2 groups only, but here I need to classify pixels into 3 groups. Any ideas will be welcome. Thanks!


1 Answer 1


One approach to distinguish between (1) vs (2)-or-(3) is to use a statistical hypothesis test. A statistical hypothesis test can tell you whether the amount of change is too large to be explained by random chance. One reasonable approach might be to use linear regression: try to model intensity as a linear function of time $y = at+b$, and then use a statistical hypothesis test to see whether the coefficient $a$ is positive (i.e., $a>0$ and the null hypothesis $a=0$ can be rejected at a 99% significance level).

Once you've identified all the type-(1) pixels, it's not clear how to distinguish between (2) vs (3), because you haven't given us a precise definition of what counts as drastic vs slow. One reasonable approach would be to again use linear regression, and then use a threshold $\alpha$: if it's not a type-(1) pixel and $0<a\le \alpha$, then classify it as type (2), else if if it's not a type-(1) pixel and $a \ge \alpha$, then classify it as type (3). You'd have to set the threshold $\alpha$ in some way that's appropriate for your application. You could of course consider variations on this, e.g., where the linear regression only considers observations from the last 10 seconds of time (or whatever), or weights more recent observations more highly, etc.

  • $\begingroup$ Thank you very much, I believe a constant threshold should suffice for distinguishing Case (2) and (3), so the 2nd paragraph of your answer is good enough. My further question is: If I know the behavior for the intensity of Group (2) pixels is likely to be inverse exponential (hence after a short amount of time the drop is slow and gradual), shall I use an inverse exponential curve instead of y = at + b? $\endgroup$ Commented Dec 23, 2015 at 6:38
  • 1
    $\begingroup$ @GreenPenguin, yes, that does sound to me like a useful improvement: you can fit it against a model, and see if it fits the model (e.g., using a statistical hypothesis test to test for statistical significance). That makes a lot of sense, if you have knowledge of what the intensity of type-(2) pixels is expected to behave like. $\endgroup$
    – D.W.
    Commented Dec 23, 2015 at 7:29
  • $\begingroup$ I am trying to work out this method, but I face a problem: I can quite safely assume a normal distribution on the pixel intensity against the equation model, but how to determine the standard deviation (s.d.) of the normal curve? I think I need to find out z = |actual intensity - intensity according to equation| / s.d. and check if the p-value of z is < 0.01. $\endgroup$ Commented Dec 28, 2015 at 6:26
  • $\begingroup$ @GreenPenguin, OK. Sounds like it'd be worth posting a new question, asking about that specific issue. (I also recommend you take a look at Statistics.SE and see whether you think you'll be more likely to get a good answer here or there.) $\endgroup$
    – D.W.
    Commented Dec 29, 2015 at 3:09
  • $\begingroup$ Thanks, I have posted a question about finding the standard deviation on math.stackexchange.com/questions/1591353/… and I am studying the answer. $\endgroup$ Commented Dec 29, 2015 at 3:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.