Bicubic Image Interpolation

Started by
9 comments, last by b2b3 18 years, 6 months ago
Apprently it goes like this 1. Get a 4x4 grid from your original image 2. Use those 4x4 known points to calculate the coeffiencients of the 2 variable cubic equation. 3. Solve Ax^3 + By^3 + Cx^2y + Dxy^2 + ... for any new point you wish to find. How do you do Step 2? What good is knowing the entire 16 term function is Step 3 if you don't know how to find A,B,C, etc? The above is all Ive been able to find on usenet (lots of "Look at this link it'll tell you"... 404!) google, or WikiPedia has any more useful info then that.
Advertisement
those a,b,c's can vary and are functions of the surrounding 16 points. lookup bezier surfaces and you'll see what they mean geometrically. it's just a weighed average of the surrounding pixels. lookup the bezier surface, and rewrite it in long form(ie without the summation symbols) and factor everything to make it nice and you got your funciton. in terms of just s and t. the corresponding coefficents are your stuff. bezier/hermite bla bla bla all names for the same thing. cubic equations they only differ in how you build them up. anyone can be transformed into anohter.

Tim
Hi,

That might not be the answer you expect but I remember that there is a great article about bicubic interpolation on the GPU in the book GPU Gems II. You might find your answer at your local barnes and nobels.

Phil
You will need 16 samples from image (4x4 grid), let fij be the image data.
It can look like this:


Then the value of f(a,b) is:
f(a,b) = SUM(i,j=0..3){ci(a) * cj(b) * fij}

where ci are cubic polynomial functions and a, b are coordinates of pixel you want to calculate. Both are in range (0..1).

For example you can use B-spline function to get B-spline interpolation. For B-spline the polynomials are:
c0(t) = 1/6 * (1 - t)3c1(t) = 1/6 * (3t3 - 6t2 + 4)c2(t) = 1/6 * (-3t3 + 3t2 + 3t + 1)c3(t) = 1/6 * t3


HTH
You can also click here and go to the convolutions tutorial (in left)... it explains this kind of stuff.
Apocalypse, the End of the World!
Quote:those a,b,c's can vary and are functions of the surrounding 16 points.


Actually, the coefficients are fixed. You just plug the 16 values into a formula, and out comes the result. It's most easily expressed as two separable 1D formulas.

I have a simple article with code on my page (and it's not a 404 :-)
enum Bool { True, False, FileNotFound };
I was assuming he wanted something of the form where just s and t are the variables. that is a cubic equation in terms of s and t and some constants, sorry if I confused.

one thing that I find interesting is how good the results are for this. considering cubics don't interpolate their control points, it's just interesting to me at least, how nice it looks.

Tim
Sorry if I wasn't clear. I know the coefficients depended on the original points. But I figured somewhere there would be equations to determine them the original points.

Anyway. I tried b2b3's solution. And it mostly works, except at any boundry. It creates weird shapes on the edges. B-Splines don't actually go through the control points, just near by, right?
these cubics only interpolate the corners. (interpolates = go through)

that is it only goes through the X's

XYYX
YYYY
YYYY
XYYX

Tim
I used to loves Aramini's technique a lot. While it is not a real bicubic interpolation (it interpolates along 2 bicubic splines, while a true bicubic will interpolate along a bicubic patch) it gives very good results. The spline parameter 'a' can be changed to whatever value you want (it haves to be in the [-1,0] range). A good 'a' value may gives you better, sharper results than Photoshop's bicubic magnification. Moreover, it is rather easy to code a simple, non-optimized version. I believe it is worth a try.

Regards,

This topic is closed to new replies.

Advertisement