MATLAB: Interpolation in an image at specific query points

interpolationmeshgrid

I am trying to interpolate an image of size 120×160 at specific query points. say R = [ r1,r2,r3,….rn]; C = [ c1,c2,c3,….cn]. I would like to interpolate the values at (r1,c1), (r2,c2)…(rn,cn) from the original image. I see that interp2, griddata,scatteredInterpolant, griddedInterpolant, seem to need a meshgrid of query points. Is there a way to estimate the interpolation at just these point (r,c)? If not, how do I convert such scattered points into a meshgrid?

Best Answer

load clown ;
imagesc(X);
colormap gray ;
[nx,ny] = size(X) ;
r = 1:ny ;
c = 1:nx ;
[R,C] = meshgrid(r,c) ;
%%do interpolation
Ri = 5 ; Ci = 5 ;
Xi1 = interp2(R,C,X,Ri,Ci) ;
% or can be used without mesh grid like below
Xi2 = interp2(r,c,X,Ri,Ci) ;