python模糊图像判断

参考博客:
python模糊图片过滤的方法
cv2.Laplacian 模糊判断
利用Laplacian变换进行图像模糊检测
核心代码:

def blurryImgs(files,clear_img_list):
    count = 0
    imgfile = files[0]
    for img in files:
        if img.endswith('.jpg'):
            image = cv2.imread(img)
            gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # 将图片压缩为单通道的灰度图
            imageVar = cv2.Laplacian(gray, cv2.CV_64F).var()
            # print(imageVar)
            '''
            8.010519273639789
            17.743206870295783
            365.8476922487119
            365.8476922487119
            '''
            if imageVar < THRESHOLD:
                count += 1
                clear_img_list.append(img)
    return count,imgfile

你可能感兴趣的:(python,图像处理,python,opencv)