def equalize_hist(image):
hist, bins = np.histogram(image.flatten(), 256, [0, 256])
cdf = hist.cumsum() # ???????
cdf_m = np.ma.masked_equal(cdf, 0) # ???????0?
cdf_m = (cdf_m - cdf_m.min()) * 255 / (cdf_m.max() - cdf_m.min()) # ????????lut[i] = int(255.0 *p[i])??
cdf = np.ma.filled(cdf_m, 0).astype('uint8') # ???????????0
return cv2.LUT(image, cdf)
评论列表
文章目录