NicolasRobidoux wrote:I'll give a try to f(x) = x/sqrt(1+x^2) and it's inverse g(x) = x/sqrt(1-x^2), for no other reason that these functions are cheap to compute. (Yes, I know IM uses LUTs to apply sigmoidal-contrast, at least now, even in HDRI mode. I don't only program for IM.)
Strange, I didn't think it did! I hated using a LUT when a function was available, and it was only one call per pixel. But then changes have been made since that function was added.
As for other functions, I was looking at the err() function for more correct calculation of discrete gaussian kernels (1D and 2D forms).
Side track... (start a new topic if you want to explore this further.)
The reason I was looking at the err() function is that, like image pixels, convolution kernel elements represent an area, effect, and not simply a point, and as such you really need the difference of the err() function (the intergral of gaussian) rather than simply a single point on the gaussian curve.
Single point Gaussians are close but not exactly correct. It can actually produce very WRONG kernels at very small values of sigma (less than 0.5), and especially close to the origin or 0 point. The 1D blur convolutions currently (and previously) solved this by use an average of 3 Gaussian samples for each kernel element. A comment in the code said that that technique came from photoshop!
However I eventually decided NOT to use the more accurate err() function as I could NOT ensure that it was available on all computer systems IM is compiled on (mobile phones for example). Besides I had other fish to fry!
The same problems is probably also true for resampling filters (and also other functions too). A resampling filter is after all very similar to a convolution kernel, which is NOT aligned strictly on perfect element to pixel alignment. That is, the origin is not at an integer image coordinate, and spacing of elements is also variable.
However for accurate Gaussian weighting values in a filter will not only need the weight 'point' but the 'area' (or scaling factor) that the weight will be applied to. That gets even harder for That is a major API change, though it is internal API changes.