# Color transform algorithm (that also works on saturation and value/lightness)?

To change particular colors in an image, generally you multiply the RGB by a transformation matrix. Image manipulation programs such as gimp & photoshop have a selective color change function that allows a user to convert pixels within a certain "distance" to the original color in some color space to a new color. Eg, changing #00f blue into #ffd pale yellow.

I'm trying to implement such a function in a <canvas>. What color space and distance definition do these algorithms typically use, and then how do they compute the transformation matrix?

• OK, made the edit. – Escher Jun 29 '17 at 6:24
• Is it understandable now? – Escher Jun 29 '17 at 8:58
• Yes, it's way more clear. – Julien Guertault Jun 29 '17 at 14:11