Error using .' TRANSPOSE does not support N-D arrays. Use PAGETRANSP​OSE/PAGECT​RANSPOSE to transpose pages or PERMUTE to reorder dimensions of N-D arrays.

I=imread('Medidas2._preview_rev_1.png');
I=double(I);
[m, n]=size(I)
[x,y]=meshgrid(1:n, 1:m); %grid initial image
r=0.5; %scale factor
[p,q]=meshgrid(1:r:n, 1:r:m); %grid final image
I2=interp2(x,y,I,p,q,'nearest'); %interpolation
figure
subplot(1,2,1),imagesc(I),axis image
title('Original','FontSize',18)
subplot(1,2,2),imagesc(I2),axis image
title('Interpolador NN ','FontSize',18)
colormap("gray")
Error using .'
TRANSPOSE does not support N-D arrays. Use PAGETRANSPOSE/PAGECTRANSPOSE to transpose pages or
PERMUTE to reorder dimensions of N-D arrays.
Error in interp2 (line 128)
V = V.';
Error in Interpolacion (line 11)
I2=interp2(x,y,I,p,q,'nearest');

 Accepted Answer

Your image I is 3D RGB not 2D
so you have to do 2D interpolation page by page
for k = size(I,3):-1:1
I2(:,:,k) = interp2(x,y,I(:,:,k),p,q,'nearest'); %interpolation
end

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!