Browse KB Articles




How is gamma calculated and applied?
KB Number: 10282 This article provides information on how gamma is implemented on our cameras (excluding Blackfly S). For information on how to implement gamma on Blackfly S, see KB 11026. This article is to document knowledge pertaining to the implementation of gamma on the cameras which support the feature. This includes implementation details such as bit depth, IIDC compliance, and LUT usage. Gamma Approximation In 8bitperpixel modes (including RGB8) gamma is applied as a sixteen section piecewise linear approximation using the camera's LUT. The number of entries of the LUT varies with the model of camera. When using image modes greater than 8 bpp gamma is applied with the same piecewise linear approximation. However, a LUT with 16+ bit depth is too large and so gamma is not applied using a LUT, but using a piecewise formula instead. The end points of each linear section are quite accurate (+/ 1), but between the end points the discrepancy from true gamma values can be quite different. Naturally, the higher the gamma value the less accurate the approximation will be in highly curved regions of the graph. Below is an example for a gamma setting of 2.5: In this case, with a gamma settings of 2.5, the effect of the piecewise approximation is visible in dark regions of images. Below is a comparison of the same scene, captured with a FL208S2M, of piecewise and true curves. Note that the piecewise image has a darker and coarser gradient in dark regions.
Gamma Calculation To calculate a true curve with gamma value 'g' and n x m bit LUT, where 'n' is the input bit depth and 'm' is the output bit depth, the formula is: This formula will produce the "true" curve for a gamma setting of 'g'. Thus it could be used to generate LUT entries which can then be loaded into the camera's LUT. Gamma Application Gamma is applied at the end of a camera's color core. The exact point at which it is applied may vary depending on the video mode. In RAW and mono modes, gamma is applied last. On certain models, RAW does not have any gamma applied (GS3U323S6C/MC). In color modes, gamma is applied after debayering and before RGB2YUV conversion (if applicable). In 8bit modes, where the LUT output is 9 bits deep, the pixel value is then reduced to 8 bpp before being transmitted. LUT Bit depth Using the convention from Gamma Calculation above, a LUT with n x m bit depth will have a maximum input value of 2^n  1, and maximum output value of 2^m1. The LUT will always have 2^n entries. In the case of n > m multiple input values will be converted to the same output value. All of our camera models which support LUT functionality have a 9 x 9 bit depth, except for the Grasshopper cameras which are 11 x 9. A camera's LUT bit depth is documented in the Technical Reference. Cameras which support gamma in 16bit modes apply it from the piecewise formula (not the LUT) at a bit depth of 16 bits. IIDC LUT Specification Before IIDC 1.32, there was no specification for LUT operation. Therefore, we defined our own LUT registers addresses and operation. Cameras which conform to IIDC version 1.32 will conform to the new IIDC LUT spec. As a result, the register addresses are different between 1.32+ cameras and 1.31 cameras. Note: IIDC v1.32+ cameras are NOT compatible with FlyCapture1 LUT API methods. To use 1.32 LUT functionality FlyCapture2 is required. Thank you for your input 