Bart (and Alan and Jim):
I think I may have a solution to the "lightening of high frequency patches" issue.
Here is the off the top of my head version that is closest to what we are doing now:
After downsampling in linear light using EWA RobidouxSoft, compute two deconvolved versions (I would prefer with the same deconvolution parameters but this is not necessary) with two different gamma, making sure to convert the two results to linear light.
Now, compute three luminance images:
1) Luminance of the non-deconvolved image
2) Luminance of the result of deconvolving through the first gamma (gamma 1, say)
3) Same as 2) with the second gamma (gamma 3, say)
At every pixel, choose the result with the median luminance (averaging ties, say) out of 1), 2) and 3).
That's it.
-----
I'll see if I can come up with something more likely to be better.
P.S. Let me explain the heuristic behind this.
What we want to do is improve LWGB deconvolution sharpening.
We don't want to do things on a per channel basis because don't want to lose monochromaticity preservation (that is, if all three channels are proportional in linear light before sharpening, it's also true after sharpening, ignoring clipping issues). See
http://www.luminous-landscape.com/forum/index.php?topic=77949.msg745796#msg745796. Performing median filtering of the three results on a per-channel basis would break this property. Averaging would not.
So, let's talk luminance.
Recall that the lower the gamma, the more noticeable dark halos, and the higher the gamma, the more noticeable light halos (of same "numerical" size).
If the pixel is part of a light halo in at least one of the two sharpened results, its sharpened luminance is higher than the unsharpened luminance. So, don't use the pixel value that corresponds to the highest luminance.
If the pixel is part of a dark halo in at least one of the two sharpened results, its sharpened luminance is lower than the unsharpened one. So, don't use the lowest one.
The key component of the heuristic consists of reversing the implications:
If you pick the median of the three results, you'll never choose the gamma creating the worst halo. Provided the other gamma creates a moderate halo in the same situation, you have successfully tamed halos.
Now, you may ask what happens when the two gammas produce luminance values that bracket the original's.
This is likely to happen on high frequency patches. Selecting the non-sharpened result in this situation will help the preservation of local averages. We want that.
-----
The above, as usual, is off the top of my head. Let's see if there is some proof in the pudding.
P.S. I just realized that there is a clear path to resolving ties: 1) (no deconvolution) is best, 2) (lowest gamma) is second best, 3) (highest gamma) is last.