Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In RGB model how many distinct hues are available?

Tags:

colors

rgb

hsb

In RGB model, each pixel is defined by 3 bytes, for R,G and B respectively. This gives a total of 224 colors, including 256 tones of grey.

It is very common to represent HSV/HSB/HSL models with floats (not bytes). Most descriptions describe hue as the "angle" in a cone, so it's sensible to treat it as a real number.

But how does this relate to the down-to-earth limit of 224 total colors..? How many distinct hues are available? More over, it seems to me that the number should depend on other parameters - saturation for instance..


Interesting reading: http://www.dig.cs.gc.cuny.edu/manuals/Gimp2/Grokking-the-GIMP-v1.0/node52.html
like image 977
emesx Avatar asked Nov 24 '12 07:11

emesx


People also ask

How many colors are in RGB model?

RGB Color Values Each parameter (red, green, and blue) defines the intensity of the color with a value between 0 and 255. This means that there are 256 x 256 x 256 = 16777216 possible colors!

How many hues are there?

It has been determined by people who determine such things that there are somewhere around 18 decillion varieties of colors available for your viewing enjoyment. That's an 18 followed by 33 zeros.

How many different colors we can create using RGB components?

The three RGB colors are each 8-bits (possible values [0.. 255], 28 = 256) of each of Red, Green, and Blue. The three 8-bit RGB components can create up to 256×256×256 = 16.7 million possible RGB color combinations, called 24-bit "color". Of course, any one real photo image will not use most of these possible colors.

How many Colours can be generated using a RGB LED?

This indirect scheme restricts the number of available colors in an image CLUT—typically 256-cubed (8 bits in three color channels with values of 0–255)—although each color in the RGB24 CLUT table has only 8 bits representing 256 codes for each of the R, G, and B primaries, making 16,777,216 possible colors.


1 Answers

In HSV, the hue is defined as

H = atan2( sqrt(3)*(G-B), 2R-G-B )

(link). In each of the six sectors (R-Y, Y-G ...), there are equally many hues. Additionally, there are six hues at the boundary between the regions. So, 6 + 6 * huesRY.

In the red-yellow sector, R > G > B, so both arguments to atan2 are positive.

 count sqrt(3) * (G-B) / (2R-G-B)
=count (G-B) / (2R-G-B)
=count (G-B) / ((G-B) + (2R-2G))

since we can apply any linear transformation to the sets of [x,y] and not change the count of its ratios, x / (x+2y) == x / y

=count (G-B) / (R-G)

if we subtract the same value from all R,G,B, the ratio does not change, so assume B=0

=count G / (R-G)
=count G / R

so, there are six times as many hues as there are ratios between two positive integers that are both below 2^8 (assuming 8 bits per channel), and six more. There are as many ratios as there are pairs of coprime positive integers. The number of positive integers below n that are coprime with n is called the Euler's totient function. OEIS lists its partial sums. There are exactly 19948 pairs of coprime positive integers below 256.

6 * 19948 + 6 = 119 694

There are exactly 119 694 different hues in the HSV model that correspond to a color in the 8-bit RGB model. Note that they are not spaced evenly.

If 8 bits per channel are used in the HSV model, then there are less colors than in the RGB model with 8 bits per channel simply because some HSV triples map to the same color while every RGB triple defines a different color.

like image 103
John Dvorak Avatar answered Oct 05 '22 06:10

John Dvorak