The PNG Guide is an eBook based on Greg Roelofs' book, originally published by O'Reilly. 
Home PNG Options and Extensions Pixel Calibration (pCAL)  
Pixel Calibration (pCAL)
The layout of the pCAL chunk is presented in Table 117.
The unit name is a label, such as kg/(m^3) or Mpc, that applies to the physical quantity represented by the image samples. Dimensionless data may either include a descriptive string (e.g., ``fractal iteration count'') or leave the unit field a null string. There are no restrictions on the length of the unit name. The X_{0} and X_{1} parameters encode the linear conversion. For an 8bit sample depth, the PNG samples range from 0 to 255; more generally, they range from 0 to M, where M = 2^{bit depth}  1. Most often, X_{0} will equal 0 and X_{1} will equal M, indicating that the PNG samples are the same as the original samples. But this need not be the case, and either of X_{0} or X_{1} may be positive or negative; the only restriction is that they may not be equal to each other. The conversion is done using integer arithmetic, according to the following equation: original_sample = (PNG_sample * (X_{1}X_{0}) + M/2) / M + X_{0} The inverse mapping is: PNG_sample = ((original_sample  X_{0}) * M + (X_{1}X_{0})/2) / (X_{1}X_{0}) Note that integer arithmetic here means that fractional values are rounded toward minus infinity, not toward zero; there's no difference for positive values, but for negative values, there is. Also keep in mind that the PNG samples are limited to the range [0,M] regardless of what the inverse mapping might give. The more general conversion, between original samples and actual physical values, can be represented by one of four possible equation types: linear (type 0), exponential (type 1), exponential with arbitrary base (type 2), or hyperbolic sinusoidal (type 3). The number of parameters required by each is 2, 3, 3, and 4, respectively, and the parameters are stored in the same ASCII floatingpoint format as described for the sCAL chunk earlier. The equations use floatingpoint arithmetic, not integer, and are given by: [0] physical_value = P_{0} + P_{1} * original_sample/(X_{1}X_{0}) [1] physical_value = P_{0} + P_{1} * e^{P2 * original_sample/(X1X0)} [2] physical_value = P_{0} + P_{1} * P_{2}^{original_sample/(X1X0)} [3] physical_value = P_{0} + P_{1} * sinh(P_{2}*(original_sample  P_{3})/(X_{1}X_{0})) Equation types 1 and 2 are equivalent in the sense that the same types of functions can be represented by either one; both are defined for convenience. For RGB or RGBA image types, the equations are applied to each of the color sample values independently, while for palette images, the equations are applied to the color sample values in the palette, not to the index values. Equation type 3 may seem odd, but it allows floatingpoint data to be reduced to integer data in such a way that the resolution of the integer data is roughly proportional to the magnitude of the original floatingpoint data. That is, for 32bit original data and 16bit PNG samples, the resolution near zero is around 10^{33}, and near ±10^{31} it is around 10^{28}. To put it another way, the resolution everywhere is about 0.4% (or 1/256) of the magnitude.


Home PNG Options and Extensions Pixel Calibration (pCAL) 