# Linear Gradient Histogram

Could someone explain to me in why the histogram of a linear black and white gradient looks as follows?

What I do not understand:

I was told that humans are more sensitive to darker and lighter tones and less to midtones. But should the histogram then not be inverted as less lighter pixels and less darker pixels are needed to get the same effect in humans?

• I just tested, roughly - Photoshop does. – Tetsujin Mar 12 '20 at 19:39
• Ps generated a hideous sawtooth from this image - too much compression/banding, I guess. A new clean gradient gave the curve as demonstrated, approximately. – Tetsujin Mar 12 '20 at 19:57
• "But should the histogram then not be inverted as less lighter pixels and less darker pixels are needed to get the same effect in humans?" Why, what effect ? "I was told that humans are more sensitive to darker and lighter tones and less to midtones" Is there some science that proves this? What is the problem to be solve here ? – Alaska Man Mar 12 '20 at 20:02

What you were told is not correct... it's backwards (or maybe you misunderstood?). The human response to light is ~ logarithmic; it takes ~ 2x as much brightness/luminance to cause the same perceptual change in tonal value. That's why "exposure" is logarithmic as well. I.e. a human is most sensitive to smaller changes in darker tones.

But at extreme dark values the visual importance of the very small differences diminishes as well.

To compensate for this the Photoshop gradient tool has a setting called smoothness, which applies what could be called "a response curve" to the gradient; by default this is set to 100%. If instead you set it to 0% you get a linear gradient and a flat histogram.

Along the x-axis of the histogram is the color intensity. Along the y-axis, are the frequency of the corresponding values. The histogram of a gradient is expected to be flat.

The appearance of the histogram you've shown curves upward at either end. This is likely associated with how the software you are using generates it. Behind the scenes colorspace or bit-depth conversions may be responsible.

Histograms generated by GIMP for the gradient in your sample image are mostly flat, as expected. Histograms of a fresh gradient are included for comparison.

• Linear color, linear histogram

People perceive light intensity logarithmically. Representing the values linearly spreads out values on the x-axis toward the right of the histogram.

• Linear color, logarithmic histogram

• Perceptual color, linear histogram

• Perceptual color, logarithmic histogram

• They're similar to the above-mentioned 'hideous sawtooth' from the posted image. A fresh new gradient gives very similar to the posted histogram. – Tetsujin Mar 12 '20 at 20:00
• @Tetsujin I've included histograms of a fresh gradient for comparison. I think the upward sweeps at either end of the histogram are caused by something peculiar to Photoshop. Perhaps associated with conversions to Photoshop's internal colorspace. – xiota Mar 12 '20 at 20:12
• I think it's probably a linear vs log type of thing - but idk enough about it to even know how to investigate :\ – Tetsujin Mar 12 '20 at 20:14
• I show both linear and log histograms. I suspect hidden colorspace or bit depth conversions. – xiota Mar 12 '20 at 20:16
• I'm not doing any conversions. I work at AdobeRGB until the final export. System is calibrated to within an inch of its life too. i.stack.imgur.com/Y5AH1.png I had the excuse to even test my calibration over RDC too, recently - that was 'fun' - superuser.com/a/1531168/347380 – Tetsujin Mar 12 '20 at 20:23

Not a direct answer but just to show how an image with a flat histogram looks, here is a 256x256 scilab generated image, leftmost pixel 0,0,0 up to 255,255,255 to the right.