| | 1 | = Short version = |
| | 2 | |
| | 3 | If you have a asinh compressed stack (C): |
| | 4 | {{{ |
| | 5 | L = BOFFSET + BSOFTEN * (exp(C / alpha) - exp(-C / alpha)) |
| | 6 | }}} |
| | 7 | where BOFFSET and BSOFTEN are supplied in the header, and alpha = log10(exp(2.5)) = 1.0857362. |
| | 8 | |
| | 9 | If you want to compress something (L) with asinh compression: |
| | 10 | {{{ |
| | 11 | BOFFSET = mean(L) |
| | 12 | BSOFTEN = sqrt(alpha) * stddev(L) |
| | 13 | C = alpha * asinh( (L - BOFFSET) / (2.0 * BSOFTEN) ) |
| | 14 | }}} |
| | 15 | |
| | 16 | |
| | 17 | = Long version = |
| | 18 | |
| | 19 | Due to the expected large range of data values in the final stacked |
| | 20 | image, saving them as compressed 16-bit integer images with linear |
| | 21 | BSCALE and BZERO scaling values is likely to offer poor |
| | 22 | reconstructions of the stacked image. This will lead either to |
| | 23 | truncation of the extrema of the image, or quantized values that are |
| | 24 | poorly spaced for the image histogram. Saving the images as 32-bit |
| | 25 | floating point values would alleviate this quantization issue, at the |
| | 26 | cost of a large increase in the disk space required for the stacked |
| | 27 | images. |
| | 28 | |
| | 29 | Transforming the data prior to writing to disk by taking the logarithm |
| | 30 | of the pixel values can resolve this, with the complication that all |
| | 31 | data values must first be made positive, which then sets the highest |
| | 32 | quantization sampling near the lowest values in the image. Following |
| | 33 | techniques used by SDSS, we have instead opted to use the |
| | 34 | inverse hyperbolic sine function to transform the data. This domain |
| | 35 | of this function allows any input value to be converted. In addition, |
| | 36 | the quantization sampling can be tuned by placing the zero of the |
| | 37 | inverse hyperbolic sine function at the most interesting pixel values. |
| | 38 | |
| | 39 | Formally, prior to being written to disk, the pixel values are |
| | 40 | transformed by C = alpha asinh( (L - BOFFSET) / (2.0 \cdot |
| | 41 | BSOFTEN) ), where L is the linear input pixel |
| | 42 | values, C the transformed values, alpha = 2.5 log10(e), and |
| | 43 | BOFFSET = \langle L \rangle and BSOFTEN = |
| | 44 | sqrt(alpha) * sigma_{L} are saved to the header as the scaling |
| | 45 | parameters used. The image is then passed to the standard BSCALE and |
| | 46 | BZERO calculation and saved to disk. |
| | 47 | |
| | 48 | To reverse this process (on subsequent reads of the image, for example |
| | 49 | in warp-stack difference calculations), the BOFFSET and BSOFTEN |
| | 50 | parameters are read from the header and the transformation inverted, |
| | 51 | such that: L = BOFFSET + BSOFTEN * (exp(C |
| | 52 | / alpha) - exp(-C / alpha) ). |