From a6f72fc4abdcc45e47e3234b18b23a2297bebb3c Mon Sep 17 00:00:00 2001 From: ville rantanen Date: Tue, 14 Jan 2014 10:10:58 +0200 Subject: [PATCH] Adjusting sharpness calc --- image_list.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/image_list.py b/image_list.py index 46ddc0e..c80dffe 100755 --- a/image_list.py +++ b/image_list.py @@ -392,11 +392,15 @@ def append_sharpness(sqlfile): def get_sharpness(filename): """ Difference in X, Difference in Y, get smaller diff = smaller sharpness. May change if bugs found.. """ - small_args="convert ( -define jpeg:size=1024x1024 -resize 1024x1024! -colorspace gray XXX -normalize -equalize ) \ + + # Resize to 1024 smaller axis, crop with golden ratio + # grayscale and equalize histogram. calculate difference between x neighbor + # and y neigbor. smaller difference = less sharp. + small_args="convert ( -define jpeg:size=2048x2048 -resize 1024^ -gravity center -crop 62%x62%+0+0 -colorspace gray XXX -equalize ) \ ( -clone 0 ( -clone 0 -roll +1+0 ) -compose Difference -composite -shave 1x1 ) \ ( -clone 0 ( -clone 0 -roll +0+1 ) -compose Difference -composite -shave 1x1 ) \ -delete 0 -compose Darken -composite -format %[fx:mean*1000] info:".split(" ") - small_args[8]=filename+'[0]' + small_args[12]=filename+'[0]' p=subprocess.Popen(small_args,stdout=subprocess.PIPE) sharpness, err = p.communicate() return float(sharpness.strip())