Search code examples
colorsmatrixrgbcolor-space

Plotting RGB spectrum as 2-d color matrix?


Any suggestions on how I might go about plotting the RGB color space as a 2-D matrix? I need a theoretical description of what's going on; a code sample or pseudocode would be helpful but is not required. Thanks!


Solution

  • If you want to represent every color in RGB space in a 2D grid, it may be impossible to avoid discontinuities / sharp borders in the result. But some mapping techniques will look better than others.

    Examples from Possiblywrong.wordpress.com post allRGB: Hilbert curves and random spanning trees:

    • Traverse the pixels of the image via a 2-dimensional (order 12) Hilbert curve, while at the same time traversing the RGB color cube via a 3-dimensional (order 8) Hilbert curve, assigning each pixel in turn the corresponding color hilbert RGB 3D->2D

    • "Breadth-first traversal of random spanning tree of pixels, assigning colors in Hilbert curve order." Breadth-first traversal of random spanning tree of pixels, assigning colors in Hilbert curve order.

    Also check out allrgb.com, "The objective of allRGB is simple: To create images with one pixel for every RGB color (16777216); not one color missing, and not one color twice."