Custom RGB colors

Re: Custom RGB colors
#9
I understand your calculation, but it results in a value of over 8 million, while my empirical calculated value is only around 29 thousand. That's a pretty big difference.

The thing is, in addition to ab being the same as ba, the components for the average color are calculated as (a + b) / 2, so you things like this:

(2 + 5) / 2 = (5 + 2) / 2 = (1 + 6) / 2 = (0 + 7) / 2 = 3.5

Note that there are of course quite a few other input values that result in an output value of 3.5. For my calculations, the 3.5 is then multiplied by 17 and the result is rounded down, giving an 8-bit color component of 59.

For reference, in case it's not obvious, the reason for the muliplication by 17 is because 15 is the largest 4-bit number, and 15 * 17 = 255, which is the largest 8-bit number. This works to double the number of bits in any number. For example, to extend a 3-bit number to 6 bits, you multiply it by (2^3) + 1, or 9. (7 * 9 = 63.) To go from 5 bits to 10 bits, multiply by (2^5) + 1, or 33. (31 * 33 = 1023.)
« Next Oldest | Next Newest »

 Messages In This Thread Custom RGB colors - by Stephen - 2014-02-20, 13:06 Re: Custom RGB colors - by Philippe Hurbain - 2014-02-20, 13:39 Re: Custom RGB colors - by Stephen - 2014-02-20, 13:53 Re: Custom RGB colors - by Travis Cobbs - 2014-02-20, 19:02 Re: Custom RGB colors - by Stephen - 2014-02-20, 20:11 Re: Custom RGB colors - by Michael Heidemann - 2014-02-20, 21:10 Re: Custom RGB colors - by Travis Cobbs - 2014-02-20, 22:05 Re: Custom RGB colors - by Michael Heidemann - 2014-02-21, 16:55 Re: Custom RGB colors - by Travis Cobbs - 2014-02-21, 21:41 Re: Custom RGB colors - by Tim Gould - 2014-02-21, 22:43 Re: Custom RGB colors - by Travis Cobbs - 2014-02-22, 0:01 Re: Custom RGB colors - by Michael Heidemann - 2014-05-02, 7:39 Re: Custom RGB colors - by Travis Cobbs - 2014-05-02, 16:44 Re: Custom RGB colors - by Michael Heidemann - 2014-05-02, 17:02 Re: Custom RGB colors - by Michael Heidemann - 2014-05-02, 11:10

Forum Jump:

Users browsing this thread: 1 Guest(s)