python+opencv检测图像清晰度
直接上代码,list_jian.txt为待检测图像路径列表
import cv2
import numpy as np
import os
for path in open("list_jian.txt"):
path = path.replace('\n', '') #去除换行符号
img = cv2.imread(path, 1)
width,height = img.shape[:2][::-1]
img_resize = cv2.resize(img,(int(width*1.0),int(height*1.0)),interpolation=cv2.INTER_CUBIC)
img_gray = cv2.cvtColor(img_resize,cv2.COLOR_RGB2GRAY)
imageVar = cv2.Laplacian(img_gray, cv2.CV_64F).var() #图像模糊度
print('>>>',path)
print(">>>",int(imageVar))

浙公网安备 33010602011771号