-1

currently I'm struggling to create a solution to resize an image(colour and greyscale) using interp1() in MATLAB. I've looked everywhere but the only solution I found is to use interp2() which is something I can't. I have been trying and researching for almost 3 days now, but nothing help. thank you in advance.

2 Answers2

0

YOu may skip few rows and columns, if you are against interpolation.

I = imread('peppers.png') ;   
size(I)
I1 = I(1:2:end,1:2:end,:) ;
size(I1)

And also, you can have a look into imresize.

I2 = imresize(I,[200 200]) ;
Siva Srinivas Kolukula
  • 1,251
  • 1
  • 7
  • 14
0

As you are strict on using interp1..you may proceed as follows. Do interpolation based on global indices.

I = imread('peppers.png') ;
[nx,ny,t] = size(I) ;
%%
dx = 4 ; dy = 4 ;   % see to it that dx and dy are multiples of nx and ny
%% Global indices 
idx = 1:nx*ny ;
% for interpolation 
idxi = 1:dx:nx ; idyi = 1:dy:ny ;
[I1,J1] = meshgrid(idxi,idyi) ;
idxi = sub2ind([nx,ny],I1,J1)' ;
%%
nxi = nx/dx ; nyi = ny/dy ;
I1 = zeros(nxi,nyi,t) ;
%%
for i = 1:t
    C = I(:,:,i) ;
    temp = interp1(idx,double(C(:)),idxi(:)) ;
    I1(:,:,i) = reshape(temp,nxi,nyi) ;
end
I1 = uint8(I1) ;
imshow(I1)
size(I)
size(I1)
Siva Srinivas Kolukula
  • 1,251
  • 1
  • 7
  • 14