octave-bug-tracker
[Top][All Lists]

## [Octave-bug-tracker] [bug #30587] buggy implementation of bicubic interp

 From: Thorsten Meyer Subject: [Octave-bug-tracker] [bug #30587] buggy implementation of bicubic interpolation in interp2/bicubic Date: Thu, 29 Jul 2010 08:53:54 +0000 User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.10) Gecko/20100623 Iceweasel/3.5.10 (like Firefox/3.5.10)

```URL:
<http://savannah.gnu.org/bugs/?30587>

Summary: buggy implementation of bicubic interpolation in
interp2/bicubic
Project: GNU Octave
Submitted by: tmeyier
Submitted on: Thu 29 Jul 2010 08:53:54 AM UTC
Category: Libraries
Severity: 4 - Important
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name: Thorsten Meyer
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: dev
Operating System: GNU/Linux

_______________________________________________________

Details:

while implementing regression tests for recent bug fixes in interp2, I came
across the following:

A=[13,-1,12;13,-1,12;13,-1,12];
x=[0,1,2]; y=[10,11,12];
xi=linspace(min(x),max(x),17);
yi=linspace(min(y),max(y),26)';

interp2(x,y,A,xi,yi,'cubic')(1,:)

gives this:
ans =

Columns 1 through 6:
13.000000    9.773438    6.968750    4.585938    2.625000    1.085938
Columns 7 through 12:
-0.031250   -0.726562   -1.000000   -0.851562   -0.281250    0.710938
Columns 13 through 17:
2.125000    3.960938    6.218750    8.898437   12.000000

in this case, the bicubic interpolation in bicubic.m is used and it gives
what I would naively expect, i.e., a parabolic fit to the three data points:

pp=polyfit([0 1 2], [13 -1 12], 2);
polyval(pp, linspace(0, 2, 17))

ans =

Columns 1 through 6:

13.000000    9.773438    6.968750    4.585937    2.625000    1.085937
Columns 7 through 12:
-0.031250   -0.726563   -1.000000   -0.851563   -0.281250    0.710937
Columns 13 through 17:
2.125000    3.960938    6.218750    8.898438   12.000000

Now, I wanted to try the other implementation of bicubic interpolation
directly within interp2, which is used for non-meshgrid xi and yi:

interp2(x,y,A,[xi; xi], [10 * ones(size(xi)); [10 11*ones(1,
16)]],'cubic')(1,:)

And here, I get the following:
ans =
Columns 1 through 7:
13.00000   11.07227    8.89062    6.60742    4.37500    2.34570
0.67188
Columns 8 through 14:
-0.49414   -1.00000   -0.71484    0.28125    1.82422    3.75000
5.89453
Columns 15 through 17:
8.09375   10.18359   12.00000

The question is: which of the two implementations is right?

_______________________________________________________

<http://savannah.gnu.org/bugs/?30587>

_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/

```