的方法有哪些?
有几种方法可以计算图片的亮度值,其中一种是使用Python的Pillow库,另一种是使用NumPy。以下是使用Pillow库的代码示例:
from PIL import Image
def brightness(im_file): im = Image.open(im_file) stat = ImageStat.Stat(im) return stat.mean[0]
另一种使用NumPy的代码示例如下:
import numpy as np import cv2
def brightness(im_file): im = cv2.