proper scaling of the Jinc filter for EWA use

Discuss digital image processing techniques and algorithms. We encourage its application to ImageMagick but you can discuss any software solutions here.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: proper scaling of the Jinc filter for EWA use

Post by NicolasRobidoux » 2012-05-03T08:14:32-07:00

The neat thing is that making the EWA result of Lanczos what I called "EWA Jinc-windowed Jinc radius 3", the corresponding filter in the orthogonal world is the plain vanilla Sinc-windowed Sinc 3, given that the distance one should use in the orthogonal world is the box distance, w.r.t. which plain vanilla orthogonal Lanczos 3 is alread "radius 3".
Let's see how thing pan out, but in terms of user expectations, what -filter Lanczos -distort Resize (or any use of -distort) does may be better this "Jinc Lanczos radius 3" than the plain vanilla Jinc-windowed Jinc 3, which is much softer than is Sinc orthogonal cousin.
On the other hand, one would then be tempted to do the same with all the main orthogonal filters, which opens the door to figuring out what the matches are (we know EWA RobidouxSharp is a good match for orthogonal Catmull-Rom, for example, but there are quite a few "pairings" to set, and then the "-distort" name of a filter does not really reflect how it does, just what it does).

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: proper scaling of the Jinc filter for EWA use

Post by anthony » 2012-05-03T19:18:46-07:00

Do you think it may be (eventually) worth while to automatically make a filter for Jinc windowed Jinc (EWA Lanczo) , auto-scales so lobes == support. EG: 3 lobes windowed Jinc, scaled to have support 3?

If we do this, perhaps it will be time to give a specific name to this: scaled jinc windowed jinc for window use.

I am not suggesting we do this NOW, just talk about it for the moment.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: proper scaling of the Jinc filter for EWA use

Post by NicolasRobidoux » 2012-05-04T04:44:10-07:00

@Anthony:
Let's wait for Adam's thesis to come out (or at least let's wait for me to have access to more quantitative results).
This being said, it does appear to me that scaling Jinc-windowed Jinc so that support = lobes gives a worthwhile scheme.
If IM was the kind of environment in which methods are given names based on the "intent" instead of the "how", I'd actually suggest that EWA Lanczos be this scheme: It appears that if you want to get an EWA version of orthogonal Lanczos, EWA Lanczos with support = lobes is a pretty good "clone". You could then access the unscaled one using simple -defines.
In a sense this issue is similar to the question of what is the standard sigma for Gaussian blur used as an interpolator.
For orthogonal Lanczos, no choice. For EWA Lanczos, lots of choices.

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: proper scaling of the Jinc filter for EWA use

Post by NicolasRobidoux » 2012-05-04T06:30:51-07:00

@Anthony:

Given that with the most important one, EWA Lanczos3, the "sharpened for vertical/horizontal preservation" ones (the current or "new" one) gives results that look almost the same as the unsharpened one (unsurprising since the blur is so close to 1), and that EWA Lanczos2Sharp is, in terms of results, more or less covered by EWA Robidoux/Mitchell, I would like to suggest this:

LanczosSharp just gives Sinc Lanczos when used "orthogonally", and gives the support = lobes Jinc Lanczoses when used the EWA way.

LanczosSharpest just gives Sinc Lanczos when used "orthogonally", and gives the maximally sharpened ones when used the EWA way.

And the current LanczosSharp (with the most recent values of (de)blur, which are just slightly different than the current ones) are just documented in Examples for those who feel like tweaking, but are not accessible w/o -defines.

Would that make sense to you? In your redefined API plans?

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: proper scaling of the Jinc filter for EWA use

Post by NicolasRobidoux » 2012-05-05T06:21:49-07:00

NicolasRobidoux wrote:...EWA Lanczos2Sharp is, in terms of results, more or less covered by EWA Robidoux...
I just checked the data and it really looks like EWA Robidoux can be described as a functional clone of (the current) EWA Lanczos2Sharp (or vice versa ;))
So, my suggestion to replace what the Lanczos*Sharp with something else than what it does now do would appear to be a good one.
P.S. EWA Mitchell-Netravali is farther. The "clone" is EWA Robidoux, not EWA Mitchell.

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: proper scaling of the Jinc filter for EWA use

Post by anthony » 2012-05-07T23:37:27-07:00

NicolasRobidoux wrote:LanczosSharp just gives Sinc Lanczos when used "orthogonally",
and gives the support = lobes Jinc Lanczoses when used the EWA way.

LanczosSharpest just gives Sinc Lanczos when used "orthogonally",
and gives the maximally sharpened ones when used the EWA way.
...
Would that make sense to you? In your redefined API plans?
That makes sense, and is quiet clear. But I'll make this change for IMv7 only, and later on (beta) when I get to looking at individual options.



IM7 Work Update: At the moment doing 'percent escapes' in almost all arguments, including geometry arguments. Exceptions are argument that store the value AS-IS for future expansion, EG: -label and -format. After that I can look at adding CLI argument handling to IM "magick scripts".
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: proper scaling of the Jinc filter for EWA use

Post by anthony » 2012-05-07T23:41:20-07:00

NicolasRobidoux wrote:P.S. EWA Mitchell-Netravali is farther. The "clone" is EWA Robidoux, not EWA Mitchell.
Sorry what is this in relation too? A documentation fix? If so where?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: proper scaling of the Jinc filter for EWA use

Post by NicolasRobidoux » 2012-05-08T04:42:23-07:00

anthony wrote:
NicolasRobidoux wrote:P.S. EWA Mitchell-Netravali is farther. The "clone" is EWA Robidoux, not EWA Mitchell.
Sorry what is this in relation too? A documentation fix? If so where?
I'm trying to establish matching "EWA Keys <-> EWA windowed Jinc" pairs.

I was stating that the Keys spline which gives an "equivalent" to EWA Lanczos2Sharp is indeed EWA Robidoux, not EWA Mitchell.

Makes sense now?

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: proper scaling of the Jinc filter for EWA use

Post by anthony » 2012-05-08T21:06:21-07:00

NicolasRobidoux wrote:
anthony wrote:
NicolasRobidoux wrote:P.S. EWA Mitchell-Netravali is farther. The "clone" is EWA Robidoux, not EWA Mitchell.
Sorry what is this in relation too? A documentation fix? If so where?
I'm trying to establish matching "EWA Keys <-> EWA windowed Jinc" pairs.

I was stating that the Keys spline which gives an "equivalent" to EWA Lanczos2Sharp is indeed EWA Robidoux, not EWA Mitchell.

Makes sense now?
Got ya.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: proper scaling of the Jinc filter for EWA use

Post by NicolasRobidoux » 2012-07-18T17:26:17-07:00

My current opinion is that setting the EWA Jinc Lanczos 3 (de)blur so that the radius of the EWA disk is exactly the same as the number of lobes produces a scheme which is just a nudge too sharp.
That is: My guess is that the best all around "sharp" EWA Jinc Lanczos 3 scheme will have a -define filter:blur values which is slightly above .9264075766146068 (the value which makes the filter support a disk of radius 3). How much above? I don't really know. But I am fairly certain that it is less than .9765193279, the (de)blur value which ensures that the radius of the disk is exactly sqrt(3^2+1^2). Probably more than a bit less.
I have some ideas RE: a criterion that would make it show up, but they are not solid, and the amount of programming involved in computing the value is not something I have time for right now.
Last edited by NicolasRobidoux on 2012-07-19T05:33:43-07:00, edited 2 times in total.

imaggie
Posts: 88
Joined: 2011-12-19T04:15:36-07:00
Authentication code: 8675308

Re: proper scaling of the Jinc filter for EWA use

Post by imaggie » 2012-07-19T00:10:40-07:00

Code: Select all

sqrt(3^2+1^2). Probably more than a bit less.
How about sqrt(3^2) ? ;)

Sorry if I've lost the plot on this, but how does the geometric mean of 3 adn 1 give you exactly three lobes ?

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: proper scaling of the Jinc filter for EWA use

Post by NicolasRobidoux » 2012-07-19T04:58:39-07:00

@imaggie: Sorry, I was sloppy, and I did not explain what I was doing.

-define filter:blur=.92... allows you to rescale the Jinc 3-lobe so that its support is a disk of radius exactly 3. This is the basis for the method I call "EWA LanczosRadius3", which has been tested quite a bit in some of my other threads. Now, I >>visually<< find this filter to have just a bit too much aliasing for my taste when enlarging. On the other hand, I find EWA LanczosSharp a bit too soft (awesome lack of jaggies, though). So, I'm looking for a (de)blur between the two that would have some basis for being called "optimal".

(3,1) is the position of the nearest "untouched" input pixel location when the disk is centered at an input pixel location located at (0,0) and one slowly enlarges the disk from radius 3.

NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308
Location: Montreal, Canada

Re: proper scaling of the Jinc filter for EWA use

Post by NicolasRobidoux » 2012-07-19T05:34:30-07:00

My wish for slightly less aliasing without loss of sharpness may be caught in a zero sum game. Which means that "EWA Lanczos Radius 3" would be as good, or as bad, as they come.
And there is something to be said for never needing more than a 6x6 square patch of data to compute a value when not downsampling. The "Radius 3" deblur is the largest one that does that.

imaggie
Posts: 88
Joined: 2011-12-19T04:15:36-07:00
Authentication code: 8675308

Re: proper scaling of the Jinc filter for EWA use

Post by imaggie » 2012-07-19T05:41:41-07:00

(3,1) is the position of the nearest "untouched" input pixel location when the disk is centered at an input pixel location located at (0,0) and one slowly enlarges the disk from radius 3.
What is 3.1 ? Presumably this is not anisotropic in x,y . Does this mean one sinc lobe equals three jinc lobes?

I'm usually a bit hesitant about this kind of arbitrary tweaking other than just to explore how things work.

Soften or blurring is basically introducing errors. Adding some small slice of an extra lobe is to add an arbitrary amount of error. Now there will be some subjective point where the arbitrary errors "optimally" masks the ringing defects.

This will largely depend upon the nature of the image: degree of colour blocks, sharp line contrasts and angle of image lines to the sampling matrix.

As I am sure you are aware there is a whole cartography of sharpness/blurring etc. for the various kinds of splines that can be used for interpolation.

Now I realise that you are searching out the last grain of improvement at this stage and the differences are barely perceptible but is adding such an arbitrary slice of a lobe mathematically any more useful than adding some small random signal or small gaussian blurring?

Adding in more lobes would generally increasing ringing, so is the subjective improvement from adding/subtracting in a slice of a lobe preferable to some other softening distortion?

imaggie
Posts: 88
Joined: 2011-12-19T04:15:36-07:00
Authentication code: 8675308

Re: proper scaling of the Jinc filter for EWA use

Post by imaggie » 2012-07-19T05:49:18-07:00

Just thinking on the hoof here, how does adding a small slice of a lobe compare to removing a similar amount?

Does adding a small slice soften , as I suspect, or increase the ringing due having fractionally more lobes ?

Post Reply