0

So I have a program that scans cameras from multiple sources and takes a thumbnail of their view at a certain time and saves them as jpg's.

I would like to now scan these through my C# program and check if any of the created jpg files are completely black (either completely obstructed, or no signal in this case).

I am wondering what would be the best way of solving this problem. Not a color depth issue.

Thanks!

Mac
  • 43
  • 7
  • Possible duplicate of [How can I check the color depth of a Bitmap?](http://stackoverflow.com/questions/2150504/how-can-i-check-the-color-depth-of-a-bitmap) – MethodMan Jan 27 '16 at 19:08
  • Not really. It is a trivial problem from the programming side, but it is not about the color depth. – TomTom Jan 27 '16 at 19:09
  • http://stackoverflow.com/questions/1068373/how-to-calculate-the-average-rgb-color-values-of-a-bitmap – CodeCaster Jan 27 '16 at 19:11
  • @CodeCaster 's link's answer would be just -excellent- for this question. I was about to suggest creating an histogram, but that would be much more complex :-) – Jcl Jan 27 '16 at 19:19
  • There's definitely some good answers that should work on there from CodeCaster's link. Hopefully the options don't run too slowly, I'll come back and update when I have time to code it up! Thanks! – Mac Jan 28 '16 at 17:36

2 Answers2

0
  • Load picture.
  • Go through all pixels and check their RGB value.
  • If you find all below a certain threshhold - assume picture is black.

Beware: you should likely ignore single pixels not being black. Sensors are not perfect. Stuck pixels are a known phenomenon.

TomTom
  • 61,059
  • 10
  • 88
  • 148
0

Use the GetPixel(x,y) function to check color at x,y location. You can iterate through the whole image and if they're all black then it's black. You can also check if majority of pixels are gray / black - if so then it's probably a very dim image.

  • I'm going to accept this. It was the simplest answer up in the link that CodeCaster posted. – Mac Jan 28 '16 at 17:40