题解|灰度图像对比度计算器
灰度图像对比度计算器
https://www.nowcoder.com/practice/9acf08634aca4a338fad76e09e7f9b16?tpId=377&tags=&title=&difficulty=0&judgeStatus=0&rp=0&sourceUrl=%2Fexam%2Foj
对比度是衡量图像对比度的一个指标,其计算公式为:
标准代码如下
def calculate_contrast(img):
max_pixel = np.max(img)
min_pixel = np.min(img)
contrast = max_pixel - min_pixel
return contrast