3

I've read some articles which introduce fast third-order interpolation using GL_LINEAR.

Because [1] contains lots of errata, I recommend reading [2] if you want to catch the formalism.

Both of them mention the restriction of this method. For filtered texture with GL_LINEAR, next relation holds only if 0 <= b/(a+b) <= 1

a*f(i, j) + b*f(i+1, j) = F(i+b/(a+b), j)

where f is original image data and F is linearly interpolated texture by OpenGL.

Here's the problem. [1] mentions that this method also can be applied to Catmull-Rom bicubic.

the method can also be adapted to interpolating filters such as Catmull-Rom splines

However, it's obvious that with Catmull-Rom weighting function which contains negative parts, the condition(0 <= b/(a+b) <= 1) cannot be fullfiled. In fact, I have tried to implement Catmull-Rom with same logic, it produces just blurry images.

Is there a special way to apply the method in [1] and [2] to Catmull-Rom interpolation? Or Do I have to fetch all 16 texels for Catmull-Rom?

Vitality
  • 20,705
  • 4
  • 108
  • 146
slyx
  • 2,063
  • 1
  • 19
  • 28

1 Answers1

1

I think that the paper by Sigg and Hadwiger is correct.

Catmull-Rom polynomial p(t) can be written as

p(t) = 0.5 [ w0(t) * p0 + w1(t) * p1 + w2(t) * p2 + w3(t) * p3]

where

w0(t) = -t + 2*t^2 - t^3;
w1(t) = 2 - 5*t^2 + 3*t^3;
w2(t) = t + 4*t^2 - 3*t^3;
w3(t) = -t^2 + t^3;

and p0, p1, p2, p3 are the sampled function values.

For the B-spline, you group together the first two terms, namely w0(t) * p0 and w1(t) * p1 and the second two terms, namely w2(t) * p2 and w3(t) * p3. For the Catmull-Rom spline, you group together w0(t) * p0 and w3(t) * p3 and w1(t) * p1 and w2(t) * p2. It is easy to verify, even by a Matlab plot, that the condition b/(a+b) is satisfied for this choice. So, the idea can be used also in Catmull-Rom interpolation. However, for the Catmull-Rom case, it seems to me that there is no possible extension to the last step, since neither (w0(t) + w3(t))/(w0(t) + w1(t) + w2(t) + w3(t)) nor (w1(t) + w2(t))/(w0(t) + w1(t) + w2(t) + w3(t)) meet the condition you specified.

Vitality
  • 20,705
  • 4
  • 108
  • 146
  • Thank you for your reply. As far as I understand the articles rightly, two pixels must adjoint each other to use the formula. In your reply, p1 and p2 are nearest neighbours, so w1p1+w2p2 can be obtained with one texture fetching. However, p0 and p3 aren't nearest neighbours. Do you think weighted sum of p0 and p3 can be obtained with one texture fetching? – slyx Nov 11 '13 at 00:46
  • @xylosper Unfortunately, I'm not expert of OpenGL. In CUDA, texture memory is optimized for local accesses and I think there could be the possibility that all those data will reside in the texture cache so that only one texture fetching is enough. Perhaps, OpenGL will be similar. – Vitality Nov 11 '13 at 20:43
  • Texture fetching in OpenGL means to obtain filtered(in this case, linearly interpolated) color(texture data) for given coordinate. So, basically, each pixel value requires one texture fetching and to obtain four pixels, I have to fetch texture four times. The key point of articles is to reduce these texture fetching from 4 times to 2 times by use of linearly interpolated filtered texture. – slyx Nov 12 '13 at 13:16