If you want to align the RGB image, u should not be converted to gray, and not align the RGB channels one at a time.
So, I think maybe this is what you need:
def equalize_hist(img): for c in xrange(0, 2): img[:,:,c] = cv2.equalizeHist(img[:,:,c]) cv2.imshow('Histogram equalized', img) cv2.waitKey(0) return img
source share