def blur_detect(im, threshold=7): """ Negative log-likelihood on the inverse gradient norm, normalized by image size """ nll = -np.log(blur_measure(im)) return nll > threshold, nll