Transpose does not support N-D arrays error
Mostrar comentarios más antiguos
Hi, I am performing image morphing using interp2, however i keep on getting the error :
Error using .'
TRANSPOSE does not support N-D arrays. Use
PAGETRANSPOSE/PAGECTRANSPOSE to transpose pages or
PERMUTE to reorder dimensions of N-D arrays.
Any idea how should I modify my code so that I can get the dimension right ?
A = imread('1.png');
B = imread('3.jpeg');
[height,width,channels] = size(A);
[X,Y] = meshgrid(1:width, 1:height);
number_of_frames = 10;
for i=1:number_of_frames
interp_x = (i - 1) / (number_of_frames - 1);
interp_y = (number_of_frames - i) / (number_of_frames - 1);
X_interp = interp_x * X + (1-interp_x) * Y;
Y_interp = interp_y * Y + (1-interp_y) * X;
results = interp2(A,X_interp,Y_interp,'linear',0);
imshow(results)
imwrite(result, sprintf('morph_%03d.jpg', i));
pause(0.1);
end
2 comentarios
Stephen23
el 3 de En. de 2023
Please show us the complete error message. This means all of the red text.
The code you show does not incude the line where the error occurs.
Christopher Gan
el 3 de En. de 2023
Respuesta aceptada
Más respuestas (1)
I'd probably adapt the "Interpolate Multiple Sets of Values on Same Grid" example from the griddedInterpolant documentation page. This uses the functionality introduced in release R2021a to interpolate multiple data sets simultaneously. See the Version History section of the documentation page linked above for more information.
A = imread('peppers.png');
A = im2double(A);
whos
Let's interpolate A to a coarser grid.
[x, y] = ndgrid(1:384, 1:512);
G = griddedInterpolant(x, y, A);
[xx, yy] = ndgrid(1:20:384, 1:20:512);
B = G(xx, yy);
Now display the two images.
subplot(1, 2, 1)
imshow(A)
title('Original')
subplot(1, 2, 2)
imshow(B)
title('Interpolated')
Categorías
Más información sobre Interpolation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

