Travis Cobbs Wrote:Combining two 12-bit colors together in a 50/50 checkerboard does not give you a 24 bits of color space.
Totally unrelated question. Do any math types out there know how to calculate the actual size of the color space for a 50/50 average of two 12-bit colors, where the results are 24-bit colors? I was curious and wrote a real quick program to come up with the number empirically (by calcuating all 16m+ combinations of 12-bit values and counting all the unique results), but the answer I got seemed very strange: 29,791 (which, for what it's worth, is 0x745F in hexadecimal). I can't decide if I messed up my (very simple) program or not. I would have expected some simple equation to give the count, but I also would have expected the result to have some kind of visible pattern in hexadecimal notation, and I don't see one.
For reference (for the programmers out there), here is the program. Store the below in a .cpp file and compile it and it should work on just about any semi-modern C++ environment. (Having said that, I've only run it as a Win32 C++ Console Application, build with Visual C++ 2010.)
Code:
#include <stdio.h>
#include <set>
int main(int argc, char* argv[])
{
std::set<int> colors;
for (int left = 0; left < 4096; ++left)
{
for (int right = 0; right < 4096; ++right)
{
int r = (((left & 0xF00) >> 8) * 17 + ((right & 0xF00) >> 8) * 17) / 2;
int g = (((left & 0xF0) >> 4) * 17 + ((right & 0xF0) >> 4) * 17) / 2;
int b = ((left & 0xF) * 17 + (right & 0xF) * 17) / 2;
colors.insert((r << 16) | (g << 8) | b);
}
}
int count = (int)colors.size();
printf("Total: %d (0x%X)\n", count, count);
return 0;
}