Coefficient computation for bicubic interpolation
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)
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
Matt J
on 20 Nov 2012
Do you have an example of what you tried?
mona
on 20 Nov 2012
mona
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
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
Matt J
on 21 Nov 2012
What version of MATLAB do you have?
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 assume you really meant to write
interp2(xs,3,'cubic');
mona
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
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.
mona
on 22 Nov 2012
Categories
Find more on Interpolation 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!