Fred and Anthony:
I am worried that convertion to and from an image format in which negative values are clamped up to zero would lead to accuracy issues, esp. when using low QUANTUM. The Rec... formats involve negative conversion coefficients; consequently, there could be some loss from converting to and from it. I actually suspect that some of the visible artifacts of clamp-locally in the rose enlargements come from this conversion. (Converting to a linear format introduces less conversion error.)
On the other hand, maybe clamp-locally is a good attempt, but actually not a good scheme?
Now:
Could you guys make things work by converting the input image to (ideally, linear) greyscale instead of an image formate with an intensity channel?
The only tricky thing is then to modify the intensity of the final result using the locally-clamped clamped greyscale "intensity" image.
The above comments are also relevant to Anthony's idea RE: ligthen and darken, not only clamp-locally.
I don't quite see whether this can be made to work.
(Apologies for terseness.)
------
Also: The preliminary results I get with Fred's code are promising, but suggest that this needs to be tweaked a bit if this will work well for "all" images, not only, say, line drawings. Also, at some point I'll need to see if LBB does bettter than bilinear and Hermite.
LBB (Locally Bounded Bicubic) is a novel, and fairly complicated, scheme, only appropriate for resampling and upsampling, not downsampling (unless you want to do supersampling before downsampling, which is probably a waste):
https://github.com/jcupitt/libvips/blob ... le/lbb.cpp