I would like to automate process of creating thumbnails / contact sheets for videos. They are usually m x n matrixes of pictures, eg 6x11 or 8x12 etc. Randomly selected pictures are sometimes bad quality: contains movement (blurry image), camera spans (blurry too), too dark or completely black, or completely white, no details, etc. Currently I am using the jpg image file size for image metric: bigger file size -> more details on the picture. Combined with number of colors (can be determined with ImageMagick "identify -format %k" command). I normalize both to 0.0-1.0 interval by dividing with the largest value in the group of the pictures and then I compute the following metric:
gamma*number_of_colors^2+(1-gamma)*file_size^2
Where gamma is a weighting parameter and can be in interval 0.0-1.0. What other approaches, image metrics can be used for this purpose?
If you are interested in sharpness/blurriness, you could go to greyscale and run an edge detection (e.g. Canny) which will give you a generally black image with white areas where sharp edges are detected. If you take the mean brightness of such an image (or count the white pixels and divide by the image area in pixels), the ones that have a higher brightness are the ones with more sharp edges.
convert image.jpg -colorspace gray -canny 0x1+10%+30% -format "%[fx:mean]" info:
So, by way of example... using this sharp image:
I test the sharpness:
convert sharp.jpg -colorspace gray -canny 0x1+10%+30% -format "%[fx:mean]" info:
0.00485202
Now, with a blurry version:
I now get this:
convert blurred.jpg -colorspace gray -canny 0x1+10%+30% -format "%[fx:mean]" info:
0.00261855