Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Resampling - Bicubic, Cubic, B-Spline

748 views
Skip to first unread message

Bill Tuthill

unread,
Jan 20, 2003, 12:47:11 PM1/20/03
to
Is the Bicubic resampling filter in Photoshop (or PaintShopPro)
the same as the Cubic resampling filter in ImageMagick and the
B-Spline resampling filter in Irfanview 3.8?

I suspect so, but have looked only at ImageMagick source code.
Thanks in advance.

Bill Zettler

unread,
Jan 20, 2003, 9:00:49 PM1/20/03
to
Almost certainly. Bi-cubic just means you're doing the splines separably
(rows, then columns). Cubic should be the exact same thing.

The B-Spline resampler might only be second-order, that is, it might
only be quadratic. There's generally no benefit to going beyond third
order (cubic). But someone who's taken the time to write the full spline
implementation probably would have done it right and gone with the
cubic. But the cubic interpolators are also splines.

HTH,
Bill

Dave Martindale

unread,
Jan 24, 2003, 4:23:50 AM1/24/03
to
Bill Zettler <bzet...@zettler.com> writes:

>The B-Spline resampler might only be second-order, that is, it might
>only be quadratic. There's generally no benefit to going beyond third
>order (cubic). But someone who's taken the time to write the full spline
>implementation probably would have done it right and gone with the
>cubic. But the cubic interpolators are also splines.

However, there likely *is* a difference between cubic/bicubic and
B-spline interpolation, even though both are splines and both are
cubics.

Both B-spline and standard cubic interpolation use an interpolation
kernel that is 4 samples wide, made up of 4 cubic polynomials spliced
together. Normal cubic polynomial interpolation designs the polynomials
so that they pass through (-2, 0), (-1, 0), (0, 1), (1, 0), and (2, 0).
This has the effect that the interpolated continuous function passes
through all the original data points. In addition, each new sample
depends only on the 16 input points closest to its location.

Cubic B-splines use a interpolation kernel that is the result of
convolving a unit-width box with itself 4 times. This has some nice
properties, but simple B-spline interpolation gives an output function
that does *not* pass through the original sample points. Each output
point depends on 16 input points, as before.

If you were to use standard B-spline math alone for image resampling,
the result would be very noticeably fuzzy. So it hasn't usually been
used for this. However, several people have noted that it is possible
to perform a special preprocessing step on the input image *before* the
resampling step that much improves the results. Essentially, it
involves calculating a set of new "control points" for the B-spline
such that the resulting interpolated function passes through the
*original* input image data points.

This preprocessing step can be treated as solving a system of
equations, but the system is tridiagonal (all matrix elements are zero
except for 3 diagonals) so solving it is cheap. Alternately, the
preprocessing can be done by a pair of special high-pass filters, one
running left-to-right and the other right-to-left. Either way, the
preprocessing step adds little extra time. But by using the
preprocessing step, the results of the B-spline interpolation become
*better* than the standard bicubic interpolation. (See "Quantitative
Evaluation of Convolution-based Methods for Medical Image Interpolation"
by EHW Meijering, WJ Niessen, and MA Viergever for a comparison. See
Wolberg's "Digital Image Warping" for one method for doing the
preprocessing.)

One difference between the two methods is that standard cubic
interpolation gives a reconstructed continuous image that also has
first-derivative continuity, while B-spline gives that *plus*
second-derivative continuity. Also, the preprocessing step makes every
new output sample depend on the value of *all* input samples, not just
the 16 nearest ones. In some sense B-spline interpolation (including
the preprocessing step) is performing a global fit to the input data,
not just a fit to the local 16 samples. Yet the interpolation step is
still done by a 16-point separable convolution, so it's almost the same
expense as plain cubic polynomial interpolation.

Dave

Bill Tuthill

unread,
Jan 24, 2003, 2:37:54 PM1/24/03
to
Dave Martindale <da...@cs.ubc.ca> wrote:
>
> Bill Zettler <bzet...@zettler.com> writes:
>> ... But the cubic interpolators are also splines.

>
> However, there likely *is* a difference between cubic/bicubic and
> B-spline interpolation, even though both are splines and both are cubics.
>
> This preprocessing step can be treated as solving a system of
> equations, but the system is tridiagonal (all matrix elements are zero
> except for 3 diagonals) so solving it is cheap. Alternately, the
> preprocessing can be done by a pair of special high-pass filters,
> one running left-to-right and the other right-to-left. Either way,
> the preprocessing step adds little extra time. But by using the
> preprocessing step, the results of the B-spline interpolation become
> *better* than standard bicubic interpolation.

Thanks for your help, Dave and Bill.

The version 3.80 of Irfanview that I downloaded has B-Spline filter
but nothing named Cubic. Interestingly, the Resample drop-down menu
says that Lanczos is slowest, and lists resampling filters as follows,
probably in order of speed:

Hermite
Triangle
Mitchell
Bell
B-spline
Lanczos

Recently I tested many filters for 25% downsampling and concluded that
Mitchell performed better than (bi)Cubic in ImageMagick, which performed
better than Lanczos. However for upsampling, (bi)Cubic and Lanczos
definitely perform better than Mitchell. I didn't try Bell.

So I wonder if this 3.80 release of Irfanview uses the preprocessing
step for B-spline resampling, and if so, why would many people say that
Lanczos performs better? ImageMagic has no filter named B-spline.

Dave Martindale

unread,
Jan 24, 2003, 3:53:00 PM1/24/03
to
Bill Tuthill <ca_cr...@yahoo.com> writes:

>So I wonder if this 3.80 release of Irfanview uses the preprocessing
>step for B-spline resampling, and if so, why would many people say that
>Lanczos performs better? ImageMagic has no filter named B-spline.

Since B-splines are pretty useless for resampling without the
preprocessing step, I think it's safe to conclude that Irfanview does use
it.

However, I didn't say that B-spline was better than Lanczos. Meijering
at colleagues concluded that B-spline was better than other methods
USING THE SAME INTERPOLATING KERNEL SIZE. So cubic B-spline with a 4x4
kernel performs better than 4x4 bicubic polynomial.

But "Lanczos" is really Lanczos-windowed sinc interpolation. In theory,
the kernel can be any size, but in my experience it doesn't perform that
well until the kernel is at least 6x6, and 8x8 is better. Panorama
Tools uses a 16x16 kernel for its "lanczos 256" interpolation. At these
sizes, the B-spline preprocessing step is probably impractical, and
Lanczos does perform better - if you're willing to wait many times as
long for the result.

So if you want good but fast, use B-spline. If you want slightly better
but substantially slower, use Lanczos.

(Also note that really wide kernels, Lanczos or any other filter, tend
to produce nasty ringing artifacts on images that weren't sufficiently
low-pass filtered before sampling. Thus, they can be a poor choice for
computer-generated images).

Dave

Bart van der Wolf

unread,
Jan 24, 2003, 8:06:00 PM1/24/03
to

"Dave Martindale" <da...@cs.ubc.ca> wrote in message
news:b0s93c$2e6$2...@mughi.cs.ubc.ca...
SNIP

> So if you want good but fast, use B-spline. If you want slightly better
> but substantially slower, use Lanczos.
>
> (Also note that really wide kernels, Lanczos or any other filter, tend
> to produce nasty ringing artifacts on images that weren't sufficiently
> low-pass filtered before sampling. Thus, they can be a poor choice for
> computer-generated images).

Very true, but I've found a blur with radius of approx. 0.3 before
upsizing with Lanczos windowed sinc even allows to do a 'good' job on
CGIs. The Lanczos does maintain very good contrast between the original
pixels, so it won't blur aliased edges. Therefore it's subject dependent
whether that's a blessing or not.

Bart


Jim V

unread,
Jan 24, 2003, 8:56:33 PM1/24/03
to
Bill Tuthill <ca_cr...@yahoo.com> wrote in message news:<v2odgvp...@corp.supernews.com>...

The best Resampler is supposidly S-spline.


http://www.s-spline.com


Jim Venner
See what I am Saying?
http://www.pbase.com/jimven/galleries

Bart van der Wolf

unread,
Jan 25, 2003, 7:59:22 AM1/25/03
to

"Jim V" <jimv...@yahoo.com> wrote in message
news:623fb113.03012...@posting.google.com...

> Bill Tuthill <ca_cr...@yahoo.com> wrote in message
news:<v2odgvp...@corp.supernews.com>...
> > Is the Bicubic resampling filter in Photoshop (or PaintShopPro)
> > the same as the Cubic resampling filter in ImageMagick and the
> > B-Spline resampling filter in Irfanview 3.8?
> >
> > I suspect so, but have looked only at ImageMagick source code.
> > Thanks in advance.
>
> The best Resampler is supposidly S-spline.
>
>
> http://www.s-spline.com

I've been told by them that they are working on a 16-bit/channel Pro
version.

Bart


Bill Tuthill

unread,
Jan 26, 2003, 2:02:06 PM1/26/03
to
Jim V <jimv...@yahoo.com> wrote:
>
> The best Resampler is supposidly S-spline.
>
> http://www.s-spline.com

So they themselves say. The same is self-said about Genuine Fractals.

However this page on Fred Miranda's website shows that his Photoshop-based
stairstep interpolation (using biCubic repeatedly) works better than either
for a picture of a lion's eye:

http://www.fredmiranda.com/SI/index.html

Of course Fred is also trying to sell something...

JL

unread,
Jan 31, 2003, 11:08:23 AM1/31/03
to

Dave Martindale" <da...@cs.ubc.ca> wrote in message
news:b0s93c$2e6$2...@mughi.cs.ubc.ca...


Do you know what kernel size Irfanview uses for it's B-Spline and Lanczos
filters? IOW, which is better (disregarding times)?
A quick test showed Lanczos to be only 17% slower.

thx, Jack

Bill Tuthill

unread,
Feb 3, 2003, 2:31:02 PM2/3/03
to
JL <jacklu2s...@yahoo.com> wrote:
>
> Do you know what kernel size Irfanview uses for it's B-Spline and Lanczos
> filters? IOW, which is better (disregarding times)?
> A quick test showed Lanczos to be only 17% slower.

Nobody has answered this yet, so I'll put my foot in my mouth.

I have not seen the source code for Irfanview. Is it available?
However I presume that the author used many freeware and copy-left
algorithms if not source code. IJG libraries for instance.

Looking at ImageMagick, the Lanczos filter runs -3 to +3 Sinc windows,
meaning it's either 8x8 or 9x9 (I'm not good with off-by-one errors).
The Cubic filter, probably similar to B-Spline, runs pixel calculations
in a -2 to +2 window, meaning it's either 5x5 or 4.4.

0 new messages