# Sensor Linearity

Sensors are linear devices. If you double the amount of light, the sensor output will double, as long as the pixels are not full[1]. Once a pixel reaches full capacity, it will give a constant or "clipped" output. Human vision is non-linear, as explained in the dynamic range topic. A doubling of the light in low light conditions has a much larger effect than in bright conditions. Our vision amplifies the shadows and compresses the highlights.

 Sensors respond in a linear way[1] to light while human vision responds in a non-linear way which is often approximated by a power curve of about 0.45. So what the sensor measures as "127" is perceived by the human vision as about "186".

If we expose this sensor until the pixels are full, then the brightest pixels will output a value of 254 (255 would be clipped). If we halve the amount of light, the brightest pixels will output a value of 127. This implies that the brightest stop uses up half of the 255 available tones and this is where human vision is least sensitive. There are only a few tones left to describe the darkest stops, where human vision is more sensitive. This creates a very dark linear RAW image with a histogram skewed to the left.

 Sensors (red curve) respond in a linear way to light while human vision (green curve) responds in a non-linear way which is often very roughly approximated by a gamma curve of 1/2.2. So what the sensor measures as "127" is perceived by the human vision as about "186" (or "2047" is perceived as "2988", as indicated in these 12 bit graphs). The blue curve is a typical tonal curve applied to the linear data to compensate for the human vision and to compress the dynamic range into the smaller dynamic range of the monitor or printer in such a way that it is pleasing to the human eye.

Therefore digital cameras apply a tonal curve to the linear raw data so that images viewed on a monitor or printed images are more pleasing to the eye. Applying a gamma correction of 1/2.2=0.45 will allocate more tones to the shadow areas and fewer tones to the highlight areas in line with the characteristics of our vision. When working in a gamma 2.2 color space like sRGB or Adobe RGB the images will appear perceptually uniform on a monitor or print, avoiding posterization (banding).

In reality cameras and raw converters go beyond a gamma correction and apply more of an S-shaped (on a logarithmic scale) curve to the data in order to "compress" the larger dynamic range so it can be represented on a monitor or print in a way that it is pleasing to the human eye.

### Technical Footnote

1. (1) In practice, there are some non-linearities in the darkest shadows and brightest highlights. Also, some cameras, e.g the Nikon D2X, preprocess the sensor data before the ADC.
 This article is written by Vincent Bockaert, author of The 123 of digital imaging Interactive Learning Suite Click here to visit 123di.com