How to interpolate the pixel resolution
3 次查看(过去 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))
0 个评论
采纳的回答
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 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!