#include #include int main (int argc, char *argv[]) { double r, g, b; int Y, u, v; int x, y; char *yuv; yuv = calloc (256*256*256, 1); printf ("P5\n4096 4096 1\n"); for (b = 0; b < 256; b++) for (g = 0; g < 256; g++) for (r = 0; r < 256; r++) { Y = (int) ((double) 0.299 *r + 0.587 *g + 0.114 *b); u = (int) ((double) 128 + -0.168736 *r - 0.331264 *g + 0.5 *b); v = (int) ((double) 128 + 0.5 *r - 0.418688 *g - 0.081312 *b); if (Y < 0 || Y > 255 || u < 0 || u > 255 || v < 0 || v > 255) fprintf (stderr, "oob: %f,%f,%f --> %d,%d,%d\n", r, g, b, Y, u, v); else yuv[(((Y * 256) + u) * 256) + v] = 1; } for (y = 0; y < 4096; y++) for (x = 0; x < 4096; x++) { Y = (x >> 8) << 4 | (y >> 8); u = x & 0xff; v = y & 0xff; printf ("%c", yuv[(((Y * 256) + u) * 256) + v]); } return 0; }