Home > Software engineering >  Is it neccessary to change the RGB color to HSL in order to change specific range of color?
Is it neccessary to change the RGB color to HSL in order to change specific range of color?

Time:12-15

I wanted to change specific range of color to another color.

For instance, i want to change all shades of yellow color to white.

CodePudding user response:

The main problem here is defining what "all shades of yellow" mean. Working in HSL space this is fairly easy, define a range of Hues that you consider to be "yellow", and apply your change to all of these colors. For example:

HSL_yellow_to_white

Working in RGB space you will need to consider a RGB cube and define part of this volume as "yellow" before applying your transformation. This will likely be more difficult.

You might also want to keep part of the original color, for example keeping the Lightness-part of the color and only changing the saturation, so that a dark murky yellow will remain dark. You might also want to define a "soft border", and apply only part of your transformation, to avoid any sharp transitions between "yellow" and "not yellow".

  • Related