2

Yes, I AM trying to re-invent the wheel. :-) . I am doing my own image compression, (testing some ideas for transmitting parts of images over tcp). Anyway... I am trying to step through 24 bit rgb color, get a complete linear range, and (step through) that range at x intervals.

I am trying to get the average 99 colors over the complete spectrum. (24bit / 99) = 167488.6363636364 , so at 16K interval I want to pic a color for my 99 color palette.

I am having trouble understanding how RGB really works... It seems the is NO linear range..., or is there...?

I am currently doing the following:

var_interval = (255 * 255 * 255) / 99

 For r = 0 To 255
     For g = 0 To 255
          For b = 0 To 255

                    If var_counter = var_interval Then
                    objWriter.Write(r & "," & g & "," & b)

                    End If

                    var_counter += 1
           Next
     Next
 Next

I am getting my colors, but this step does not generate "scaling" colors if you will.

Any ideas?

pavium
  • 14,808
  • 4
  • 33
  • 50
Louis van Tonder
  • 3,664
  • 3
  • 31
  • 62
  • There isn't a *linear range* of colors. Since there are RGB components you need to consider a three-dimensional approach, and while you *could* define linear paths though 3D color space, which *direction* would you choose? – pavium Jun 26 '11 at 09:27
  • precisely.... :-) That is what I am finding... its all just a big pile of colors, with no real standard structure? – Louis van Tonder Jun 26 '11 at 11:06
  • So in a case like this, do I have to go and "choose" my own colors for the palette? – Louis van Tonder Jun 26 '11 at 11:06
  • Coincidentally, I'm currently trying to figure out how to choose 100 *distinct* colors from the 16.7 million, for mapping purposes. I might try to turn it into a Question, but I've favorited your question and I'll leave a comment if I find something. – pavium Jun 27 '11 at 02:04
  • Cool, so we leave this here then for now? – Louis van Tonder Jun 27 '11 at 12:03

1 Answers1

3

There certainly is a way to iterate through the color spectrum, but whether you go this approach is your own choice :). You can make use of the HSL color space (Hue, saturation, and lightness) instead of RGB (red, green, blue). The hue represents which color (ranging from 0 to 360), the saturation is how much of that color your want (0 to 100), and the lightness is how bright you want it.

So, to answer your question, you can take 360/99 as your sampling rate from the hue, choose a consistent value and intensity that you'd want and then convert that to RGB space to display it. For the conversion see: http://web2.clarkson.edu/class/image_process/RGB_to_HSI.pdf

and for information on HSL color space see: http://en.wikipedia.org/wiki/HSL_and_HSV

Noremac
  • 3,445
  • 5
  • 34
  • 62