Does anybody have details about how Matlab does its 2-D 'spline' interpolation?

I didn't find details about how Matlab computes its 'spline' interpolation in interp2. Apparently, it uses many points (Roughly a square of 60 points are needed to obtain exactly the same interpolation as for the whole plan when I tried for an example implying a huge matrix of random numbers (see example below) (and it's probably only a precision limit)). (I understood that 'linear' uses 4 points, 'cubic' 16) Does anyone know how Matlab procedes (I don't think they give any reference or anything about their method...)
MATLAB CODE
X=ones(1000*2,1)*(1:500);
Y=((((1-round(1000/2)):1000+...
(1000-round(1000/2))))')*ones(1,500);
Z=rand(2000,500);
rt=59.5
Hum3=interp2(X,Y,Z,rt,rt,'spline')
for kj=1:floor(rt-1)
if isequal(interp2(X((500+floor(rt)-kj):(500+ceil(rt)+kj),(floor(rt)-kj):(floor(rt)+kj)),...
Y((500+floor(rt)-kj):(500+ceil(rt)+kj),(floor(rt)-kj):(floor(rt)+kj)),...
Z((500+floor(rt)-kj):(500+ceil(rt)+kj),(floor(rt)-kj):(floor(rt)+kj)),rt,rt,'spline'),Hum3)
disp(kj)
break
end
end

5 Comments

Did you look into the code of INTERP2 already?
i dont know how many points they use exactly but i learned one thing: never use spline interpolation on noisy signals :)
I looked in interp2, but it uses some functions to which we have no access...
Finally, I think that by definition of a spline they have to use all the points (because at each point there is the derivative and second derivative criterion which links each couple of points with the two previous ones, therefore linking all the points (whenever the link to the closest points will be stronger)).
Why do you say that we should never use spline on noisy signal? (I have peaks and noise in between... Is it a bad case for spline interpolation?) (and in one of the dimensions the peaks could be seen as a "noisy thing" (only some pixels per peak (maybe 1-3)))
the problem is, that the following can easily happen: http://imgur.com/e5hPj
Yes, you are right, thank you. Apparently the 'cubic' option is less prone to this unwanted distortions... (I am doing some tests..)

Sign in to comment.

Answers (0)

Categories

Asked:

on 18 Jul 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!