Search code examples
pythonpython-3.ximage-processingscikit-image

detect and select nonblack images in a folder


I am currently working on a media project. We've shooted looong clips, mainly dark if not black. I have decomposed these clips into their frames (>500k single frames) and put them in some folders. Now, my goal is to find out and select those frames that are not black or mainly dark: it's around a thousand out of the total.

This seems a job that a simple Python script can handle without too much effort. I know that scikit-image is quite common to work with images, but don't know how to come up with a script that does the job neatly. I have some experience with scientific programming but this with images manipulation is a bit out of my field.

For example, this image should be reported as black and thus ignored, while this other one, although in low light, should be kept as good.

Ideally, it would be optimal to have a script that uses one or more criteria to determine if an image is totally dark or not, and in the latter case put it into another folder for human (me) inspection.

Any help is exteremely appreciated!


Solution

  • Opencv is enough to solve this problem.

    use np.mean(image, axis=2) to get mean of different channels, then you can easily check the black ones.