1
$\begingroup$

I have a C# desktop application.

Its purpose is to detect motion changes between consecutive frames.

Currently I am using the excellent Emgu wrapper to OpenCV.

Now, I know this question may seem ridiculous but it is an extreme example to demonstrate best what I mean by the question.

I have a complete white background.

Snow begins to fall..

I actually want to detect the motion changes.

Obviously the contrast is appalling and my normal way of detecting motion pixels by comparing the RGB values will need to have a really low threshold.

At the moment I use 10% difference. Any less than that and I will incur noise from more 'contrasted' images.

I could look at the edges instead of the color changes.

I could try to write a test that will detect a low contrast image and lower the threshold to 5% (e.g.).

I will of course attempt these 2 things now.

but is there a more obvious approach to this?

I could post code that shows how I compare the pixels of each image and report motion but that would be a very basic thing to post. But will do if asked.

The way I see it a human can detect this motion of snow so I just need to find what rules would allow my code to do the same thing.

UPDATE For me I decided to improve the gamma of an image to help me with poor contrast. This is the code I used:

double intensity = grayCurrent.GetAverage().Intensity;
double g = Math.Log(Shared.Optimum, 256) / Math.Log(intensity, 256);
if (g != 1)
{
    grayCurrent._GammaCorrect(g);
}

What I am doing here is get the average 'darkness' of the overall image. I then found that 'log' formula on my Google Searches travels. I then, by trial and error determined that the shared optimum for my particular application is 75. I then say if the 'balance' is '1' then do not change anything. If it is off the 'norm' then make the changes to the overall image.

$\endgroup$
  • $\begingroup$ There are literally hundreds of image processing methods to improve contrast and to remove noise. You'd better apply those methods before comparing images. To get more help, you need to help your helper to understand and try your problem. In order to do that, posting your code and images first is a better way. $\endgroup$ – Tae-Sung Shin Mar 24 '14 at 19:57
  • $\begingroup$ Hi. thanks for taking the time to comment. you are quite right I should have been more specific. I have solved my particular issue by using a gamma threshold. I thought I had deleted this and will do so once you have read this $\endgroup$ – Andrew Simpson Mar 24 '14 at 20:35
  • 1
    $\begingroup$ I suggest you do not delete your post but add your solution as an answer so that you can help others having similar problem. $\endgroup$ – Tae-Sung Shin Mar 24 '14 at 21:55
  • $\begingroup$ Hi, I was hoping you would say that. It is specific for me though. My solution may not actually help you detect snow against a white background. I used that as an extreme example. I will answer my own question to show what worked for me. $\endgroup$ – Andrew Simpson Mar 25 '14 at 7:35
  • $\begingroup$ Thanks. It would not help me as I am not interested in this problem right now, but it may somebody else in near future. I believe it (sharing our knowledge) is whole point of this community. $\endgroup$ – Tae-Sung Shin Mar 25 '14 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.