From 3485c49e9570c593286ea5d6a3c4cb31d669de4d Mon Sep 17 00:00:00 2001 From: hexa6six Date: Tue, 12 Mar 2019 19:27:00 +0100 Subject: [PATCH] Update Sorter.py BlurEstimatorSubprocessor now uses the full aligned image for sharpness estimation instead of the masked image estimate_sharpness now calculates the variance of the laplacian operator. see here: https://www.pyimagesearch.com/2015/09/07/blur-detection-with-opencv/ --- mainscripts/Sorter.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/mainscripts/Sorter.py b/mainscripts/Sorter.py index edd18b9..eac7980 100644 --- a/mainscripts/Sorter.py +++ b/mainscripts/Sorter.py @@ -21,17 +21,8 @@ def estimate_sharpness(image): if image.ndim == 3: image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) - - sharpness = 0 - for y in range(height): - for x in range(width-1): - sharpness += abs( int(image[y, x]) - int(image[y, x+1]) ) - - for x in range(width): - for y in range(height-1): - sharpness += abs( int(image[y, x]) - int(image[y+1, x]) ) - - return sharpness + + return cv2.Laplacian(image, cv2.CV_64F).var() class BlurEstimatorSubprocessor(Subprocessor): @@ -54,9 +45,6 @@ class BlurEstimatorSubprocessor(Subprocessor): if dflimg is not None: image = cv2_imread( str(filepath) ) - image = ( image * \ - LandmarksProcessor.get_image_hull_mask (image.shape, dflimg.get_landmarks()) \ - ).astype(np.uint8) return [ str(filepath), estimate_sharpness( image ) ] else: self.log_err ("%s is not a dfl image file" % (filepath.name) )