Filter löschen
Filter löschen

How to interpolate the pixel resolution

2 Ansichten (letzte 30 Tage)
Ima
Ima am 26 Jul. 2014
Kommentiert: Ima am 5 Aug. 2014
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))

Akzeptierte Antwort

Jian Wei
Jian Wei am 29 Jul. 2014
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)')

Weitere Antworten (1)

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

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by