How to fade color

后端 未结 8 1296
我寻月下人不归
我寻月下人不归 2021-02-06 05:56

I would like to fade the color of a pixel out toward white, but obviously maintain the same color. If I have a pixel (200,120,40), will adding 10 to each value to m

8条回答
  •  星月不相逢
    2021-02-06 06:31

    @mark-meyer's answer is good, I answered a similar question on the StackMathematica section in great detail with examples PartOne and Part Two.

    For THIS question, gradient to full white, here are examples using my gradient explorer:

    Left column is staying in sRGB, next is linear xyY, then LAB, and far right is LAB LCh

    You'll notice that remaining in sRGB is not substantially different than using L*a*b* in most cases. This is partly because sRGB has a gamma curve that is different but similar to the perception curve of LAB.

    You'll notice though that the LCh version has some hue shifts, depending on the starting color. In the case of purple, it requires some offsets near the mid range.

    Also with LCh, the direction (clock wise or CCW) of hue rotation makes a difference.

    Looking just at the for right LCh, here is magenta start, with no offsets, and the natural rotation:

    Same rotation direction, but some offsets to smooth the LCh gradient.

    Reversing the hue rotation and different offsets we go through purple instead of orange for LCh:

    And here's from yellow, the LCh gets a green tinge without adjusting the hue offset:

    But offsetting the mid hue smooths the LCh gradient:

    And finally. BLUE is tricky with L*a*b* as it often wants to shift to purple. On the other hand, in LCh blue wants to shift to cyan:

    So in truth you can typically stay in sRGB for things like gradients to white, but for gradients between two saturated colors you might prefer to use LCh:

    So here where colors get closer to 180° apart, the middle gets desaturated for both sRGB and LAB, as the average value in the middle is a grey - a darker murky grey for sRGB and a lighter grey for LAB. But LCh maintains saturation and instead rotates through the hues.

提交回复
热议问题