I have a gray-scale image and I want to make a function that
- closely follows the image
- is always grater than it the image
- smooth at some given scale.
In other words I want a smooth function that approximates the maximum of another function in the local region while over estimating the that function at all points.
Any ideas?
My first pass at this amounted to picking the "high spots" (by comparing the image to a least-squares fit of a high order 2-D polynomial) and matching a 2-D polynomial to them and their slopes. As the first fit required more working space than I had address space, I think it's not going to work and I'm going to have to come up with something else...
What I did
My end target was to do a smooth adjustment on an image so that each local region uses the full range of values. The key realization was that an "almost perfect" function would do just fine for me.
The following procedure (that never has the max function explicitly) is what I ended up with:
- Find the local mean and standard deviation at each point using a "blur" like function.
- offset the image to get a zero mean. (
image -= mean;
) - divide each pixel by its stdev. (
image /= stdev;
) - the most image should now be in
[-1,1]
(oddly enough most of my test images have better than 99% in that range rather than the 67% that would be expected) - find the standard deviation of the whole image.
- map some span +/- n*sigma to your output range.
With a little manipulation, that can be converted to find the Max function I was asking about.