1

I've been searching for an image that contains all possible rbg colors, but I simply cannot find one. I'm starting to think that's it's impossible, since what I'm looking requires 3 dimensions.

I tried looking for things like "color wheel" or "hsv color" but I have been unable to find exactly what I'm looking for.

Is it even feasible to try to find a 2d image to represent a full rgb color scheme? And if yes, where can I find one?

To be explicit, I want a 2d image containing all (rgb) values (0-255, 0-255, 0-255)

2

1 Answer 1

1

There are 16,777,216 (256^3) possible RGB color combinations, so a square image in which each color is assigned a single pixel would have dimensions of 4096 px by 4096 px.

The following Processing code will generate such an image:

int numLevels = 256; // Number of levels per color channel
int numChannels = 3;

int dim = (int)sqrt(pow(numLevels, numChannels)); 
int curX = 0, curY = 0;
color curColor;

void setup(){
  size(dim, dim);
  colorMode(RGB);
  noLoop();
}

void draw(){

  for (int rVal = 0; rVal < numLevels; rVal++){
    for (int gVal = 0; gVal < numLevels; gVal++){
      for (int bVal = 0; bVal < numLevels; bVal++){
        curColor = color(rVal, gVal, bVal);
        set(curX, curY, curColor);
        curX++;
        if (curX >= dim){
          curX = 0;
          curY++;          
        }
      }  
    }    
  }

  save("rgb_colors.tif");

}

Most operating systems won't allow Processing to create a window large enough to display the entire image, but the full-size image will be saved as rgb_colors.tif and placed in the same directory as the script.

2
  • Change the value of numLevels and alter the colorMode() call such that the optional max argument is set to 2 to the power of the number of bits. Aug 13, 2014 at 16:35
  • (My comment above was added in response to a comment/question from joojaa about how to handle different bit depths; I suppose it must have been deleted since then. At any rate, for regular 8-bit RGB my comment above can be ignored.) Aug 13, 2014 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.