Change a particular color in an Image Python
Hi there,
I have an image and I would like to change a particular colour on that. Particularly, the image contains a set of colours I have used a means algorithm in order to obtain the whole set of colours contained in the image and selecting just one colour I would completely change it. For instance, in the image I have (as already said) the set of different colors I would like that this RGB source
RGB_source=(5, 114, 121)
change in:
RGB_dest=(166, 109, 82)
How may I manage this color change?
thank you
Attention: in a "normal" image (like a photo) the values of the pixels change a lot: there is noise, difference in exposure...so probably 2 pixels of the same color will have different RGB values. Of course this is not the case for syntetic images (i.e. drawn using Paint).
To change only a single color (as in question), you just compare the value of each pixel with
RGB_source
, and if they match, replace the value withRGB_dest
.please show how you get the means, since using KMeans() would already give you the resp. cluster indices