18% gray color code in photoshop

Started 2 months ago | Questions thread
Toermalijn Forum Pro • Posts: 15,738
Re: 18% gray color code in photoshop

Iliah Borg wrote:

Alireza S wrote:


Anybody knows the exact color code of 18% gray card in professional photography (which is used in custom white balance)?

So please give me that color code in photoshop (in HSB).


For a colour-neutral matrix-based RGB colour space (all working RGB spaces are that) this code depends on the gamma of the space. For gamma=1 spaces HSB code in Photoshop is (0,0,18), where brightness is B=18 because it is 18% grey that we want.

Saturation S is obviously 0, hue H is irrelevant as soon as S=0 and can be H=0 or any other number, brightness

B ≈ ((18%/100%)^(1/gamma))*100%

≈ in the above is for the following reason: the stated gamma and the actual gamma in the profile may be slightly different because of how gamma is coded in the profile. For the stated gamma 2.2 the actual value in the profile is often 2 + 51/256, like it is in Adobe RGB

RGB for 18% grey is computed in a similar manner,

R = G = B ≈ ((18%/100%)^(1/gamma))*255

None of this depends on anything but colour neutrality and gamma. White point and primaries are not a part of the calculation.

Since gamma coding in profiles is not exact, and CIE rounding rules are complex, the best way to know is to test with your profile.

To do so, you can open a new document in Photoshop, set the profile you want to test in the "Advanced" section of the "New" dialogue, click OK, click the foreground colour box in the Photoshop tool palette and enter Lab values (50, 0, 0) - it will show rounded HSB and RGB codes.

It is easy to see that for gamma = 1 colour space 0.18*255 = 45.9, and if you enter (0, 0, 18) into Photoshop HSB for a gamma = 1 space the RGB readout is (46,46,46), while Lab is rounded to (50,0,0)

Alternatively, for better accuracy, you can start with an RGB document in 32 bits (floating point), setting it to the profile you want to test as in previous and clicking OK. What we are using here is the following feature of floating point documents: they are linear, gamma = 1, because tone curve / gamma is discarded, but will be applied when converting the document to 8- or 16-bit representation.

add a Solid Color layer with HSB = (0,0,18)

Now we can convert the image to 16 bit to account for gamma / tone curve, setting "Merge" option and "Exposure and Gamma" method (exposure set to 0 not to apply any brightening, gamma is set to 1 not to apply additional tone correction on top of the gamma in the profile - profile gamma and gamma set for this conversion are applied one after another, so we need gamma =1 here):

Now you can sample the colour and check the value for the foreground, HSB is (0,0,46), RGB is (117,117,117), L* is rounded to 50:

If you want even better precision and going to use some real colour calculator, for 18% L* is 49.4961 because directly from the Lab formulas, L = 116*0.18^(1/3) - 16 = 49.496107610119595

Excellent explanation.

Adobe uses rgb 118 though, is that due to rounding numbers? The Wikipedia site says 119...

Keyboard shortcuts:
FForum PPrevious NNext WNext unread UUpvote SSubscribe RReply QQuote BBookmark MMy threads
Color scheme? Blue / Yellow