Reputation: 93
I want to convert a color-coded image to grayscale. The colors in that image correspond to given values (e.g. black is 0 and red is 25) like on this color scale.
Is there a way to convert this image to grayscale and keep that color gradient, so that 0 on the scale remains black and 25 is shown as white?
I tried to convert it with matplotlib and also cv2 but ended up with grayscale images, that did not respect my given color gradient. I would appreciate an answer very much. Thank you!
Upvotes: 0
Views: 409
Reputation:
Depending on the tools you use you can
or
The second approach is more efficient.
Update:
Upon reading your last comment (which should be in the original question), the options become
or
Upvotes: 1