个人记录使用,一个最简单的关于人脸模糊的分类代码
第一个模块是亮度(还没加入分类器中使用,备选特征)
第二个模块是模糊度(利用tenengard算子)
第三个模块是画图(检查图片的亮度和模糊度大致的分布区间)
第四个模块是配合第三个画图用的(print一些数据)
第五个模块是直接分类用(在第二个模块设置好threshold后来进行文件夹分类)
此方案大概率抛弃,做个记录以防万一。
import os
import cv2
import math
import shutil
import numpy as np
from skimage import filters
from PIL import Image, ImageStat
from matplotlib import pyplot
blur_list = []
light_list = []
def image_brightness(rgb_image):
"""
检测图像亮度(灰度平均值方法)
"""
stat = ImageStat.Stat(rgb_image)
r, g, b = stat.rms
return math.sqrt(0.241 * (r ** 2) + 0.691