Nearest Neighbor Interpolation
Nearest Neighbor Interpolation
0 1
Q#5: Write a code in Matlab to perform the Zooming In/Out using Nearest Neighbor Interpolation
clc; image=imread('cameraman.jpg'); [r c]=size(image); t=input('press 1 for Zoom In: \npress 2 for Zoom Out: \n'); if(t==1) i=input('enter the zoomin value: '); i=[r+i c+i]; res=imresize(image,i,'nearest'); imshow(res); elseif(t==2) i=input('enter the zoomout value: '); i=[r-i c-i]; res=imresize(image,i,'nearest'); imshow(res); end
Original image 1
ZOOM IN IMAGES
Zoomin image( c)