[Images] Simple Automatic Image Qualification

In the high altitude balloon “Space Camera Live” there is obviously a camera. Transmitting those live images takes some time. In between transmitting, the camera has time to take multiple images. If it does so, it would be smart to select the best one. But how can one select the best image? I have made a very simple algorithm that judges images only by looking at their standard deviation and mean values.

Designing an algorithm: what defines a good image?

Because extracting a total historgram takes too much time for many images on a slow processor, and is prone to error, i found out you only need simple numbers. I used imagemagick to get the mean and standard deviation values (so 3 channels, 2 values per channel = 6 values).
So i took 700 images i made in the previous launch, and ran them through. I immediatelly saw that low standard deviations are bad (little detail=lot of “grey”(clouds) or “dark”(space) or “light”(overexposed) were not good. Too high in standard deviation turned out to be bad as well (a lot of white (overexposed) and a lot of black (space)). Then, average values seemed important too. I looked at some samples, and found out an average “blue” value was existant in almost all good images.

Reference values

I took just two reference values: (1) the average standard deviation of all channels (desired 8-bit value 30), and (2) the mean of the blue channel (desired 8-bit value 160).

The algorithm

Well, a cubic one seems to suit this well. I also decided that the results were good, so i did not need to weigh the two components (since the mean value is much larger than the stdev).

[latex]Score=sqrt[2]{(Stdev_{desired}-Stdev_{measured})^{2}+(Mean_{desired}-Mean_{measured})^{2}}[/latex]

Of course, this algorithm works well on this subject “space pictures”. If you are going to have a sample of automatized pictures of any other subject, it would suck.

The automatic result on a sample

The shellscript i used for this (Linux)

Eventually, from the last “10 images” it will just choose the best one to transmit, using the ‘core’ of this core i used to produce the images you can see here attached on this page.

  1. #!/bin/bash
  2. for f in *.JPG
  3. do
  4.  
  5. 	STDSTR=`identify -verbose $f | grep "standard deviation:" | tr -d "nr:"`
  6. 	MEANSTR=`identify -verbose $f | grep "mean:" | tr -d "nr:"`
  7. 	stdarr=($STDSTR)
  8. 	meanarr=($MEANSTR)
  9.  
  10. 	STDR=`printf "%.0fn" ${stdarr[2]}`
  11. 	STDG=`printf "%.0fn" ${stdarr[6]}`
  12. 	STDB=`printf "%.0fn" ${stdarr[10]}`
  13. 	STDAVG=$(echo "($STDR + $STDG + $STDB)/3" | bc -l)
  14. 	STDAVG=`printf "%.0fn" ${STDAVG}`
  15.  
  16. 	MEANR=`printf "%.0fn" ${meanarr[1]}`
  17. 	MEANG=`printf "%.0fn" ${meanarr[4]}`
  18. 	MEANB=`printf "%.0fn" ${meanarr[7]}`
  19. 	MEANAVG=$(echo "($MEANR + $MEANG + $MEANB)/3" | bc -l)
  20. 	MEANAVG=`printf "%.0fn" ${MEANAVG}`
  21.  
  22. 	SCORE=$(echo "sqrt ( (50-$STDAVG)^2 *2 + (160-$MEANB)^2 )" | bc -l)
  23. 	SCORERAP=$(echo "(50-$SCORE)/5" | bc -l)
  24. 	SCORERAP=`printf "%.0fn" ${SCORERAP}`
  25. 	SCORE=`printf "%.0fn" ${SCORE}`
  26.  
  27. 	echo "$f,$STDR,$STDG,$STDB,$MEANR,$MEANG,$MEANB" #| tee -a "log.txt"
  28. 	convert $f -pointsize 40 -stroke black -fill white -draw "text 6,42 '$SCORERAP'" "c_"$f
  29. 	#if [ ${SCORE} -ge 15 ]
  30. 	#then
  31. 		#echo "no"
  32. 	#else
  33. 		#cp $f "/home/tim/Desktop/keuze/"
  34. 	#fi
  35. done

Tim Zaman

MSc Biorobotics. Specialization in computer vision and deep learning. Works at NVIDIA.

You may also like...