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