Re: Interaction of pCAL and gAMA
John Bowler <[email protected]>
| Newsgroups | gmane.comp.graphics.png.general |
|---|---|
| Message-ID | <CAP7U39_Ji24jZ-BdbRFnw-qf2j17sZzfj_SLjA4s9PSCf9cO5w@mail.gmail.com> |
On Thu, Jan 21, 2016 at 3:18 PM, Glenn Randers-Pehrson <[email protected]> wrote: > The PNG extensions document, which specifies the pCAL chunk, does not > address the interaction of pCAL and gAMA. Since the purpose of the pCAL > chunk is to relate PNG data to physical values, I think that gamma==1 > should > be assumed, if there's no gAMA chunk. I'd say that if both are present, it > means that the pCAL conversion should be made, then when displaying > that, assume that whatever the gAMA chunk says should be used with > the already-converted samples. But since the relationship isn't specified, > most anything could happen, for example, a viewer could only recognize > the gAMA chunk and ignore the pCAL chunk, and the display would not > likely be what the author intended. > Surely that's the wrong way round. For one thing the output of pCAL is dimensionally often not going to be luminance, but a display can only show luminance. E.g. suppose the original data is height about sea level; what does it mean to send 20ft to a monitor, or 1E8 microns for that matter? My question is based on the assumption that the numbers that are input to pCAL are dimensionless; not even luminance. gamma correction is a dimensionless transform, it takes a number and outputs a different number both in the range 0..1. The way pCAL is written is in terms of sample values, but when you simplify the equations you get back to 0..1 +/- offset, thus (just doing equation type 0, which is the only one I'm interested in ;-) original_sample = (stored_sample * (x1-x0) + max/2) / max + x0 physical_value = p0 + p1 * original_sample / (x1-x0) So, combine and simplify: physical_value = p0 + p1 * ((stored_sample * (x1-x0) + max/2) / max + x0) / (x1-x0) physical_value = p0 + p1 * (stored_sample / max + 0.5) + x0 / (x1-x0)) I think I got that right, but I did math in email again (and last time I got it wrong). So I have 'stored_sample/max' which is a number in the range 0..1, so I can use the value from the original PNG IDAT or I can use the value made linear. Both make sense, but the linear value is more useful because pCAL itself lacks a way of encoding: physical_value = p0 + p1 * pow(original_sample/(x1-x0), p2) I.e. it lacks a power-law encoding. I can't imagine that this was an omission because, obviously, that's what luminance is typically encoded with and the authors of pCAL were aware of that, however it is totally unspecified so far as I can see. John Bowler ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 _______________________________________________ png-mng-misc mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/png-mng-misc