title: On the algorithm of transforming image histogram into linear shape
body: <p>I am a beginner in opencv and I am using python. I encountered a difficulty, which is to define the histogram of a grayscale image into a linear shape, or how many pixels there are for each grayscale value, like the following:
  My goal is to regulate the histogram of the grayscale image on the left into the shape on the right:</p>
  <p><a href="https://i.stack.imgur.com/3Fzzn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3Fzzn.png" alt="enter image description here" /></a></p>
  <p>I have no ideas, I would like to ask you all, thank you for your answers</p>