Steve Mann covered this in some mathematical detail his paper called "Comparametric Equations with Practical Applications in Quantigraphic Image Processing", IEEE Transactions on Image Processing, Vol. 9, No. 8, August 2000.
The section, starting on PDF page 4, is called "On the Value of Doing the Exact Opposite of What Stockham Advocated", and describes exactly both this problem, and the solution.
Link: http://www.eyetap.org/papers/docs/comparametric.pdf
The section, starting on PDF page 4, is called "On the Value of Doing the Exact Opposite of What Stockham Advocated", and describes exactly both this problem, and the solution.