OpenCV判断图片是否模糊

合理用最简单的拉普拉斯算子,可以参考这篇文章:https://my.oschina.net/u/4611954/blog/4585054

# image = cv2.imread(imagePath)
def variance_of_laplacian(image):
    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    return cv2.Laplacian(image, cv2.CV_64F).var()

# 越大越清晰,越小越模糊

 

Leave a Reply

Your email address will not be published. Required fields are marked *