How to interpolate the pixel resolution

2 次查看(过去 30 天)
I am trying to learn interpolation which I will use in my job. These are the code I was practising, but I have error at the end.. Please can someone help me through on how to debug to clear off the error.. Error: Error using griddedInterpolant The grid vectors do not define a grid of points that match the given values.
Error in interp2/makegriddedinterp (line 214)
F = griddedInterpolant(varargin{:});
Error in interp2 (line 127)
F = makegriddedinterp({X, Y}, V, method,extrap);
Error in ex_for_interpolation (line 21)
imagesc(interp2(x_axis,y_axis,A,new_x_axis,new_y_axis))
% The codes x_axis = 1:15; y_axis = 1:25;
A = x_axis'*y_axis;
subplot(2,2,1)
imagesc(A)
axis equal
subplot(2,2,2)
% show the same data, but interpolated, by adding one additional pixel to each gap:
imagesc(interp2(A))
axis equal
subplot(2,2,3)
% show the same data, interpolated to any axis of your choice:
new_x_axis = x_axis(1):0.1:x_axis(end);
new_y_axis = y_axis(1):0.2:y_axis(end);
imagesc(interp2(x_axis,y_axis,A,new_x_axis,new_y_axis))

采纳的回答

Jian Wei
Jian Wei 2014-7-29
Please try the following code after you create the new_x_axis and new_y_axis.
[x_mesh,y_mesh] = meshgrid(x_axis,y_axis);
[new_x_mesh,new_y_mesh] = meshgrid(new_x_axis,new_y_axis);
imagesc(interp2(x_mesh,y_mesh,A',new_x_mesh,new_y_mesh)')

更多回答(1 个)

Image Analyst
Image Analyst 2014-7-29
Why not just use imresize()? It would be so much simpler.

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by