One can create variants of the popular tensor ("orthogonal") Lanczos resampling filter (Sinc-windowed Sinc 3-lobe) by changing the window function. ImageMagick offers a plethora of choices. There is one that I may have been the first one to try: Jinc-windowed Sinc.

It's not completely absurd to use Jinc as a windowing function when resampling images: From a frequency response viewpoint, the ideal filter in 2D is the Jinc function (used in a radial way, not tensor way). If one believes that self-windowing is best, one consequently wants to use the Jinc function for windowing. However, the Jinc function used as a radial filter gives a resampling scheme which is not interpolatory (which generally makes it a bit blurry). Given that a tensor product of Sincs is interpolatory, windowing the tensor Sinc function with the Jinc function would appear to make the best of a situation in which one wants a tensor Sinc to be interpolatory, but wants to keep Jinc as a window function from a 2D frequency response viewpoint.

-----

The above rationalization is most likely bunk. As Anthony Thyssen (and others?) has pointed out, small differences in windowing functions make even smaller differences in image results, and for this reason it's pretty hard to really know which windowing function is best (in general). Very very roughly, as one goes from top to bottom in the window functions shown in

(plot by Anthony Thyssen http://www.imagemagick.org/Usage/resize/#hann)

one decreases both sharpness and halo, and one increases jagginess (esp. when enlarging), at least when using three Sinc lobes (which is not surprising: basically you get a 2-lobe method when the window function is strongly bell shaped).

Again very approximately, the smoother (or blurrier) the image, the higher in the list one should choose a window function, and the more lobes one should use as well.

The first lobe of the Jinc function (which is not shown in the graph) is slightly more bell-shaped than the first lobe of the Sinc function (in the graph, Lanczos means Sinc windowing). The next one in the graph is the first lobe of the Cosine, which is right at the threshold of being bell shaped (it's concave all the way, with vanishing second derivative right at the limit of the window). (Aside: Cosine actually gives a pretty good window function if you are enlarging a blurry image.) In any case, one expects Jinc windowing to lead to slightly less haloing, and possibly a bit more jagginess, than Sinc (Lanczos) windowing. As it turns out, Jinc windowing unnoticeably affects jagginess (it may actually reduce it slightly?), and it reduces the haloing by an amount which is below JND in most images, at least when using sigmoidization, but nonetheless clearly visible in some cases, like the "firemen" image below. To a "devil in the details" kind of guy, this is enough to justify a good name.

In addition, Jinc-windowed Sinc does allow getting the same amount of halo suppression with a slightly lower value of the sigmoidization contrast.

The contrast value that makes an enlarged black square on a white background remain black within 2.3 JND (approximately [8,8,8] in 8-bit sRGB) is 11.6933.

With the usual warning that at this point only bleeding edge ImageMagick 7 compiled in HDRI mode is guaranteed to give best results, here is the code for the sigmoidized Ginseng ("Jinc-Sinc") scheme:

Code: Select all

`magick input_small.png -colorspace RGB +sigmoidal-contrast 11.6933 -define filter:filter=Sinc -define filter:window=Jinc -define filter:lobes=3 -resize 300% -sigmoidal-contrast 11.6933 -colorspace sRGB Ginseng3.png`

P.S. Warning: The test images are not very high quality. In particular, many contain a significant amount of haloing.