Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I'm trying to implement a bicubic interpolation algorithm. In order to calculate the interpolated values, I need to calculate sixteen coefficients used in the calculation process - and that's where I'm stumped.

So far I've tried to use the calculation methods for univariate functions as explained by Paul Bourke in his article on interpolation methods, calculating the coefficients for each vertical coordinate individually, using this data to determine the function values at the selected Y coordinate, using those values to calculate the coefficients for the given slice of the function and calculate the function value for the given X coordinate. This technically works, but does not give the same results as expected.

Using the first coefficient calculation method described by Bourke, the image is closer overall but includes visible artifacts: http://i.stack.imgur.com/gT500.png

Using Catmull-Rom splines (as described by Bourke), image is smoother but differs far more from the example I'm trying to recreate): http://i.stack.imgur.com/R2de6.png

"A Review of Some Image Pixel Interpolation Algorithms" by Don Lancaster and the Wikipedia article on bicubic interpolation show decidedly different results using same data values.

Both describe what (I assume) should be the correct way of calculating the coefficients - the final formula itself is pretty clear, but relies on determining several partial derivatives and cross products.

It has been several years since I had calculus and while I understand what a partial derivative is, I no longer remember how to actually calculate it from given function values. I'm completely clueless as to the cross products - the subject might not have been actually covered during the calculus and linear algebra courses I took.

I'd appreciate advice as to how I should proceed to properly determine those values.

share|improve this question
    
I think you'll have a much better chance of getting useful answers if you explain what the images show and describe in more detail, preferably explicitly giving the formulas, what you calculated. I for one am not able to fully understand the question in its current form, and as far as I understand it, I have no idea where the problem might be since you don't show your calculations. –  joriki Sep 16 '12 at 18:15
    
Sorry, SE did not allow me to include more than two links per post. The images show a result of interpolating the following set of data: {{5,4,2,3}, {4,2,1,5}, {6,3,5,2}, {1,2,4,1}} As per Lancaster's article (<tinaja.com/glib/pixintpl.pdf >), edge areas have the unknowns filled in with the value of nearest known data point. I'm using the methods described by Paul Bourke here: <paulbourke.net/miscellaneous/interpolation > –  Michał Gawlas Sep 16 '12 at 18:57
    
This is the PHP code that produced the results showing in the image (trimmed down to ie the actual interpolation algorithm). <pastebin.ca/2204737 > The BicubicInterpolator class exists because the coefficients are reused when sampling the same grid area multiple times. I know I have reversed the numbering of a[0] through a[3] in comparison to Bourke's example; this is so that I can keep the addressing somewhat logical in other parts of the code, with the array position of each value also indicating which power of the argument it will be multiplied with. –  Michał Gawlas Sep 16 '12 at 19:01
    
This is how the interpolated results should look like, according to Wikipedia and Lancaster's article: < upload.wikimedia.org/wikipedia/commons/thumb/d/d5/… > –  Michał Gawlas Sep 16 '12 at 19:07

1 Answer 1

up vote 1 down vote accepted

It turns out that formulae for calculating both required derivatives and the cross-derivative can be found in from Chapter 3.6 of "Numerical Recipes in C" (2nd Edition), p136.

The chapter is available on the book's official website: http://www.nrbook.com/a/bookcpdf.php

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.