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 11-7.
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 X0 and X1 parameters encode the linear conversion. For an 8-bit sample depth, the PNG samples range from 0 to 255; more generally, they range from 0 to M, where M = 2bit depth - 1. Most often, X0 will equal 0 and X1 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 X0 or X1 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 * (X1-X0) + M/2) / M + X0 The inverse mapping is: PNG_sample = ((original_sample - X0) * M + (X1-X0)/2) / (X1-X0) 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 floating-point format as described for the sCAL chunk earlier. The equations use floating-point arithmetic, not integer, and are given by: [0] physical_value = P0 + P1 * original_sample/(X1-X0) [1] physical_value = P0 + P1 * eP2 * original_sample/(X1-X0) [2] physical_value = P0 + P1 * P2original_sample/(X1-X0) [3] physical_value = P0 + P1 * sinh(P2*(original_sample - P3)/(X1-X0)) 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 floating-point 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 floating-point data. That is, for 32-bit original data and 16-bit PNG samples, the resolution near zero is around 10-33, and near ±1031 it is around 1028. 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) |