Both of these assume a linear transfer function, which is rarely the case.
Basically never for 8-bit color channels.