You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
Coefficient computation for bicubic interpolation
4 views (last 30 days)
Show older comments
Dear Community Members,
Since bicubic interpolation for an image requires 16 coefficients which will eventually form the window with which we would convolve the sampled image, right. So my question is "how could I calculate these coefficients?". Do I have to get the matrix of the input image through matlab? If yes, how? Kindly don't suggest imread since it only shows how many rows and columns are present. If no, what is an exact way of computing the coefficients for bicubic interpolation?
Thanks in advance
Answers (1)
Matt J
on 20 Nov 2012
Edited: Matt J
on 20 Nov 2012
Normally, you would use interp2, griddedInterpolant, or the spline command to do bicubic interpolation.
Only in very special cases, like if you are interpolating at gridded sample points, can the operation be formulated as a convolution, and even then, griddedInterpolant probably does this for you internally.
18 Comments
mona
on 20 Nov 2012
Yes, here it is: bicubic=[1 4 6 4 1; 4 16 24 16 4; 6 24 36 24 6; 4 16 24 16 4; 1 4 6 4 1]; These coefficients were convolved with the input image later.
Using spline was trial and error thing and hence I wouldn't prefer to use it unless somebody could convince me to. This is because my results were horrible and not even close plus my input is an image and not a numerical data and hence I immediately assumed that spline wouldn't work for it. What are your suggestions on the filter? I basically filled in the repeated values wherever there were zeros.
Now how did I get these values? I basically made assumptions that since bicubic is parabolic in nature and hence the equation would be close to y=x^2.
mona
on 21 Nov 2012
That's exactly my point in the question which I repeat: "how could I calculate these coefficients?" or more precisely relating to your comment, "how could I compute or know the locations at which the interpolation process needs to be carried out?"
Matt J
on 21 Nov 2012
Edited: Matt J
on 21 Nov 2012
When you perform an interpolation operation, the locations at which you interpolate are the raw input data and are supposed to be known a priori by you. They are not something that gets computed over the course of the operation.
For example, if I have the data [10,20] and I associate them with the locations [1,2] and I want to interpolate at the locations [1.5,1.7], I would do as follows
>> interp1([1,2], [10 20], [1.5,1.7],'spline')
ans =
15 17
mona
on 21 Nov 2012
This would have been fine given my input would have been numerical which is not the case since my input is an image. In case of an "Image", I am basically sampling it eight times after which I need to see the matrix of the image. Hence my next question already stated above, "Do I have to get the matrix of the input image through matlab? If yes, how?".
Matt J
on 21 Nov 2012
Well, your terminology is a bit confusing. I don't know why an "image" is something you consider a non-numerical thing. An image is just a 2D numerical array
However, here is what I suspect you want: I suspect you are given an image of dimensions NxN and you want to obtain an upsampled version of this image that is 8Nx8N. If that's the case, you would do
F=griddedInterpolant(yourImage,'cubic');
locations=linspace(1,N,8*N);
newImage=F({locations, locations});
mona
on 21 Nov 2012
First of all, Thanks for all your help.
Second, How does this method works. I'm trying to access it's functionality through help command but there's no documentation on it plus for some reason, this function is undefined in Matlab.
Third, I am trying to reconstruct an image using cubic interpolation. I have an image, I intentionally down sampled it ten times. Using this down sampled image, I am trying to reconstruct it using cubic interpolation.
Matt J
on 21 Nov 2012
If you have an old version of MATLAB, you can also upsample by factors of 2^n by doing
newImage = interp2(yourImage,n, 'spline');
mona
on 21 Nov 2012
I have 7.9.0 R2009b, Maybe its not supported. Since I'm doing cubic interpolation instead of spline, interp2(xs,'cubic'); appeared appropriate but the image got even more distorted.
mona
on 21 Nov 2012
No, I didn't mean to since 'n' is giving out of memory error even though the code itself makes sense.
Matt J
on 21 Nov 2012
Edited: Matt J
on 21 Nov 2012
Not sure why that's what you wnat. If you do interp2(xs,'cubic'), you will upsample xs by a factor of 2, whereas earlier you said you wanted to upsample by a factor of 8.
Anyway, if you don't like the result, it's either because your data is bad or else it's not very cubic.
mona
on 21 Nov 2012
It's not about ther result, I am not getting it at the first place with interp2(xs,3,'cubic'); I'm getting out of memory error.
Matt J
on 21 Nov 2012
Edited: Matt J
on 21 Nov 2012
My 2nd remark was referring to the factor-of-2 upsampling result, not the one that gave you an out-of-memory error.
Earlier, you said you thought that result looked distorted. If it looks distorted, the only thing to blame is either the data or the interpolation model.
See Also
Categories
Find more on Read, Write, and Modify Image in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)