def leftRightHistEqualize(self, img_left, img_right) :
lookup = np.zeros([256], np.uint8)
cdf_new = np.zeros([256])
rows,cols = img_right.shape
img_left_new = np.zeros([rows,cols], np.uint8)
hist_left = cv2.calcHist([img_left],[0],None,[256],[0,255])
hist_right = cv2.calcHist([img_right],[0],None,[256],[0,255])
cdf_left_norm = hist_left.cumsum() /(rows*cols)
cdf_right_norm = hist_right.cumsum() /(rows*cols)
for i in range(0,256):
lookup[i] = np.argmin(np.abs(cdf_left_norm[i]-cdf_right_norm))
# cdf_new[i] = cdf_right_norm[lookup[i]]
img_left_new[ np.where(img_left==i) ] = lookup[i]
return img_left_new
评论列表
文章目录