Convert image to grayscale image
The simple way is to compute the average of RGB colors values \begin{aligned} r = \alpha r + \beta \\ g = \alpha g + \beta \\ b = \alpha b + \beta \\ \end{aligned}
code here