Given the triplet R, G, B and factor F, how can I calculate the “watermark” of a color?

I have a triplet (R, G, B) where each color is between 0.0 and 1.0. Given the F factor (0.0 means the original color and 1.0 means white), I want to calculate a new triplet, which is the “watermark” version of the color.

I use the following expression (pseudo-code):

for each c in R, G, B:
    new_c ← c + F × (1 - c)

This creates something that looks fine, but I understand that it introduces deviations from the color cast (checking the HSV equivalent before and after the conversion), and I don't know if this should be expected.

Is there a "standard" (with or without quotation marks) algorithm for calculating the "watermark" color version? If so, what is it? If not, what other algorithms can you tell me?

+3
source share
2 answers

In fact, it looks like it should give the right shade, minus the small variations for arithmetic rounding errors.

This is certainly reasonable, it was just to achieve the effect of watermarks. I do not know other "standard" ones, there are several ways to do this.

Alternatives:
Mix with white, but do it non-linearly at F, for example. new_c = c + sqrt(F)*(1-c), or you can use other non-linear functions - this can help the watermark look more or less "flat."

You could do this more efficiently by doing the following (where F takes a range of 0..INF):

new_c = 1 - (1-c)/pow(2, F)

for real pixel values ​​(0..255) this translates to:

new_c = 255 - (255-c)>>F

, , 32b- .

+3

?

new_c = F*c

, , .

new_c = 1- * (-1)

0

Source: https://habr.com/ru/post/1771507/


All Articles