0

I have a series of images from a slow motion capture of pulsing electrical discharges. Many of the frames are nearly black. I would like to selectively keep the frames that are more interesting; eg have more luminosity.

I've considered using ImageMagick or GraphicsMagick (or any other; not married to any tool - I'm up for more efficient suggestions).

How would I go about selecting such images and then discarding the other images without appreciable luminosity levels? I'm assuming that I have to establish a baseline first of "black" and then perhaps visually find the least luminous frame image and then use that as the lower limit to use for getting meaningful images / frames...

Example of DISCARD ("empty" frame):

blank

Example of KEEP (frame with "data"):

data

ylluminate
  • 12,102
  • 17
  • 78
  • 152

2 Answers2

1

I would suggest ImageMagick to Erode the image (clean-up noise), reduce data to a monochrome binary image, and print the statistical mean of the image.

convert 5HzsV.jpg -format "%[mean]" -monochrome -morphology Erode Diamond  info:
# => 0
convert lLZFX.jpg -format "%[mean]" -monochrome -morphology Erode Diamond  info:
# => 149.992

So a bash script might be as easy as...

for image in $(ls *.jpg)
do
   L=$(convert "$image" -format "%[mean]" -monochrome -morphology Erode Diamond  info:)
   if [[ $L -gt 0 ]]; then
       echo "Image $image is not empty! @ $L"
   fi
done

Of course that can be adjusted to meet your needs.

emcconville
  • 23,800
  • 4
  • 50
  • 66
  • I'm curious. I have so much in the way of video footage to process, do you have any thoughts in the way of processing videos without extracting all frames and just going at it frame-by-frame in order to reduce the additional size from storage of the "blank" frames? – ylluminate Aug 21 '17 at 20:07
0

The way images are encoded, you'll likely find that the 'interesting' images are bigger, because the uniformly dark background compresses better than a random spark. For instance, your empty Jpeg is 21K while the interesting one is 39K.

xenoid
  • 8,396
  • 3
  • 23
  • 49
  • That's not a bad idea. Big problem here is that I don't have all of the frames extracted yet as I was working on figuring out a method to do frame-by-frame analysis vs having all of them stored out into folders first. – ylluminate Aug 21 '17 at 20:08
  • You can do some sampling of the current ones, and establish a threshold size. – xenoid Aug 21 '17 at 21:47