# opencv打卡21: 直方图归一化

1、介绍

2、实现代码

import cv2
import numpy as np
import matplotlib.pyplot as plt

def hist_normalization(img, a=0, b=255):
c = img.min()
d = img.max()

out = img.copy()

# normalization
out = (b - a) / (d - c) * (out - c) + a
out[out < a] = a
out[out > b] = b

return out

H, W, C = img.shape

# histogram normalization
out = hist_normalization(img)

# Display histogram
plt.hist(out.ravel(), bins=255, rwidth=0.8, range=(0, 255))
plt.savefig('result.png')
plt.show()



3、思考：

out = (b - a) / (d - c) * (out - c) + a
out[out < a] = a
out[out > b] = b

04-14 36

05-06 1038

03-01 803

04-13 33

10-31 2万+

10-01 5万+

06-04 8429

09-26 725

03-19 80万+

04-14 56万+

02-19 16万+

02-27 7万+

02-28 4万+

03-01 12万+

03-01 11万+

03-03 6188

03-04 12万+

03-05 9740

03-05 5万+

03-08 6万+

03-08 1万+

04-25 6万+

03-10 12万+

03-10 17万+

03-10 6361

03-12 10万+

03-13 10万+

03-16 1万+

03-19 7万+

03-20 5046

03-23 1万+

03-24 3万+

03-25 2万+

03-25 8万+

03-27 1万+

03-29 20万+

03-29 9万+

03-30 14万+

05-21 2909

03-31 1万+

05-25 5211

03-23 1万+

04-02 3万+

05-06 2万+

04-05 1万+

04-06 6万+

04-09 1万+

04-09 7万+

04-09 4711

04-10 4251

04-11 2万+

04-15 5万+

04-18 1万+

04-18 3783

04-18 4万+

04-20 3万+

04-24 2万+

04-26 3661

04-24 4100

04-30 7514

05-16 4万+

05-08 3万+

05-10 1899

05-11 3万+

05-13 6751

05-19 5676

05-13 9760

05-14 3664

05-14 6135

05-16 1945

05-16 1340

05-16 9353

05-16 1万+

05-17 4205

#### Python识别图片中的文字

©️2019 CSDN 皮肤主题: 1024 设计师: 上身试试