## BC-splines with 2C+B=1 are optimal for EWA resampling

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

### Re: BC-splines with 2C+B=1 are optimal for EWA resampling

Now that RobidouxSharp is an official IM method, here is the key data for this Keys cubic (I probably should have cleaned this up earlier; ah well). Whenever possible, I use an expression which is less prone to round off (sum of positive numbers instead of mixed sign sums).

Code: Select all

``````C = 7/(2+12*sqrt(2)) = 0.3689927438004929
B = 6/(13+7*sqrt(2)) = 0.2620145123990142
first zero crossing = (45+14*sqrt(2))/(19+28*sqrt(2)) = 1.1058229337190195``````
Last edited by NicolasRobidoux on 2012-04-23T07:11:01-07:00, edited 2 times in total.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308

### Re: BC-splines with 2C+B=1 are optimal for EWA resampling

While I'm at it, I may as well do the same for the Robidoux Keys cubic:

Code: Select all

``````C = 113/(58+216*sqrt(2)) = 0.31089212245300067
B = 12/(19+9*sqrt(2)) = 0.37821575509399866
first zero crossing = (123+36*sqrt(2))/(47+72*sqrt(2)) = 1.1685777620836932``````
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308

### Re: BC-splines with 2C+B=1 are optimal for EWA resampling

I also made sure that the B+2C=1 with the truncated values. This only affects the 17th digit. Irrelevant.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308

### Re: BC-splines with 2C+B=1 are optimal for EWA resampling

NicolasRobidoux wrote:The above RobidouxSharp comes from minimizing the worst case deviation from the original value when the original value is one of the two extremes (0 and 255 in typical 8 bit).

An alternate way is to minimize the worst case deviation when the original value is the average of the largest and smallest possible values (for example, 127.5 in typical 8 bit). I will give this a try later.

It would not surprise me if this one lands almost on top of Mitchell-Netravali.

P.S. It's not. I should have remembered that minimizing the L^1 norm generally gives sparsity, and indeed the minimizer is the Keys cubic which is equal to 0 at sqrt(2):
B = (9-3*sqrt(2))/7 = 0.67962275898295921
and
C = 0.1601886205085204
which, in principle, should be quite blurry.

P.S. 2... and indeed it is pleasant, and very blurry:

Code: Select all

``convert rose: -define filter:c=.1601886205085204 -filter Cubic -distort Resize 3000% rose_RobidouxSoft.png``
If it's OK, I would like to add this one as a named filter, under the name "RobidouxSoft".
There is starting to be quite a bit of evidence that Keys cubics work well with EWA, and although the Robidoux cubic is great for downsampling, it is found to be a bit "too sharp" when upsampling. I am not the only one who has noticed that:
http://www.luminous-landscape.com/forum ... #msg624780
http://www.luminous-landscape.com/forum ... #msg722531

P.S. I think that this filter may work well enlarging through linear light, say

Code: Select all

``convert rose: -colorspace XYZ -define filter:c=.1601886205085204 -filter Cubic -distort Resize 3000% -colorspace sRGB rose_RobidouxSoft.png``
When I have a minute, I'll check.
Last edited by NicolasRobidoux on 2014-06-12T01:11:47-07:00, edited 3 times in total.
magick
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

### Re: BC-splines with 2C+B=1 are optimal for EWA resampling

Ok.
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

### Re: BC-splines with 2C+B=1 are optimal for EWA resampling

I do not see RobidouxSoft listed when I do the following. Was it actually added, but just not listed?

convert -list filter

Code: Select all

``````Bartlett
Blackman
Bohman
Box
Catrom
Cosine
Cubic
Gaussian
Hamming
Hann
Hermite
Jinc
Kaiser
Lagrange
Lanczos
Lanczos2
Lanczos2Sharp
LanczosSharp
Mitchell
Parzen
Point
Robidoux
RobidouxSharp
Sinc
SincFast
Spline
Triangle
Welch
``````
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308

### Re: BC-splines with 2C+B=1 are optimal for EWA resampling

Fred: I said I would add it, but have not done it yet. May take me a while.
I got the OK from magick to add RobidouxSoft and LanczosSharpest.
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

### Re: BC-splines with 2C+B=1 are optimal for EWA resampling

NicolasRobidoux wrote:Fred: I said I would add it, but have not done it yet. May take me a while.
I got the OK from magick to add RobidouxSoft and LanczosSharpest.

Sorry, I misread the post. I though Magick was saying OK that he would add it. My mistake. No hurry. Just curious.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308

### Re: BC-splines with 2C+B=1 are optimal for EWA resampling

Fred (and henrywho?):
If I remember correctly, you are among some (?) who liked EWA Catmull-Rom.
After years of finding this stance somewhat strange, I am finally seeing situations in which such a brutally sharp Keys EWA may be useful. I am actually considering values of Keys alpha = BC-spline C even larger than .5.
Goes to show...
For now, I am sticking to "use a Keys when doing EWA with a BC-spline" as a rule of thumb (this of course is the point of this thread), but I am not 100% sure of that anymore.
The result has a reasonable theoretical basis. But reality is often more complicated than theory.
Last edited by NicolasRobidoux on 2014-06-26T05:07:31-07:00, edited 1 time in total.
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

### Re: BC-splines with 2C+B=1 are optimal for EWA resampling

Yes, I generally like the sharpness from the Catrom (keys cubic convolution) or Lagrange and can usually live with the other artifacts. Of course there are cases where Moire is very bad and I would then use other filters. However, I generally just use the defaults as reasonable compromises. If I were a professional photographer, I would likely be more critical.
henrywho
Posts: 188
Joined: 2011-08-17T06:46:40-07:00
Authentication code: 8675308

### Re: BC-splines with 2C+B=1 are optimal for EWA resampling

Yes, I always tell my friends to use linear light downsizing with EWA Catrom or Lagrange, while they keep using USM to (/hoping to) recover the highlight lost after downsizing in sRGB. EWA Catrom is an overkill in most cases, though.
NicolasRobidoux
Posts: 1944
Joined: 2010-08-28T11:16:00-07:00
Authentication code: 8675308