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))

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM