i write this one for gray image but i looking for rgb's too (nearest neighbor)
I1=[50 80 100 ; 115 21 90 ;32 50 160];S=2 ;[M , N]=size(I1);M2=S*M;N2=S*N;I2=zeros(M2 , N2);for i =1:M2 for j = 1:N2 x =i/S; y=j/S; x2=round(x); y2=round(y); if (x2<1)||(x2>M)||(y2<1)||(y2>N) I2(i , j)=0;else I2(i,j)=I1(x2 ,y2);end endend
Best Answer