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.
Asked
Active
Viewed 348 times
-1
-
1Why you can't _interp2_ ? – Siva Srinivas Kolukula Jun 01 '17 at 08:21
-
I understand that it is easier for me to use interp2 but in this question, i can only use interp1. – thanh thai Jun 01 '17 at 08:34
-
I have been looking at this [post](https://stackoverflow.com/questions/6183155/resizing-an-image-in-matlab) and trying to refer to it but something is still wrong or missing. – thanh thai Jun 01 '17 at 08:37
-
If you have a RGB image read as I, you can try using: I = I(1:2:end,1:2:end,3) etc..... – Siva Srinivas Kolukula Jun 01 '17 at 08:42
-
@SivaSrinivasKolukula yes I have to work with both RGB and greyscale but I still don't understand what you mean. Can u explain that further? thanks. – thanh thai Jun 01 '17 at 08:48
2 Answers
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
-
I must use interp1() in this problem and imresize() must not be used in this case. thanks in advance. – thanh thai Jun 01 '17 at 08:59
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