I have a 2D image which contains R G and B values. I think this should be purely based on averaging of pixels and selecting the threshold to decided whether this is day picture or night one.

Can you provide any kind of different ideas to solve this problem?

I am shifting this question from the https://stackoverflow.com/questions/28157035/given-an-image-how-should-i-detect-this-is-a-day-picture-or-night-picture?noredirect=1#comment44685520_28157035

  • $\begingroup$ Off-topic: It reminds me of a parable in which Americans tried to train ANN's for automatic recognition of Soviet and US tanks. They collected data, trained their system. During the in-field testing it turned out that performance is worse than random. After much research they realized all US tanks were shot in beautiful sun of California, whereas pictures of Soviet machines were shot by spies during night. That's how Americans made the world's most sophisticated system to recognize between night and day ;) $\endgroup$
    – jojeck
    Jan 27, 2015 at 10:26

1 Answer 1


This will work only if you're dealing with natural scenes (no artificial light sources).

I think there are two other possible ways:

1) looking for the percentage of dark pixels (define a threshold) that will tell you how many black areas are present in the image. Again, this will work only if we're not considering photos close to artificial light sources. Doing an average of the pixel value will lower the result if you have many lights in the scene, considering only dark areas could lead to better result (if there are enough in the scene).

2) Natural light have some difference in frequencies than artificial light, you could search which one is more present in the photo. I'm thinking at night pictures of cities for example, where lights are often in the yellow range. But i think this seems easier to say than implement, and looks more conditioned to the type of photo (natural panorama, city images, etc.).

P.S: i'm assuming the picture has been taken with the correct exposure time

  • $\begingroup$ I will try out this options $\endgroup$
    – Learner
    Jan 27, 2015 at 10:53

Your Answer

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

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