Transpose does not support N-D arrays error
이전 댓글 표시
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
Stephen23
2023년 1월 3일
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
2023년 1월 3일
채택된 답변
추가 답변 (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')
카테고리
도움말 센터 및 File Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

