0% found this document useful (0 votes)
305 views

Nearest Neighbor Interpolation

The document shows the code and output of a Matlab program that performs operations on an array. The code initializes an array with values from 0 to 7, divides each element by 7, takes the square root of each element, multiplies each element by 7, and plots the resulting array. The plot shows the transformed array values from 0 to 7 on the x-axis.

Uploaded by

Zarnigar Altaf
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
305 views

Nearest Neighbor Interpolation

The document shows the code and output of a Matlab program that performs operations on an array. The code initializes an array with values from 0 to 7, divides each element by 7, takes the square root of each element, multiplies each element by 7, and plots the resulting array. The plot shows the transformed array values from 0 to 7 on the x-axis.

Uploaded by

Zarnigar Altaf
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

7

clc; arr=[0 1 2 3 4 5 6 7]; arr=arr/7; arr=sqrt(arr); arr=arr.*7; plot(arr); grid;

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 (a) Zoomin image (b)

Zoomin image( c)

ZOOM OUT IMAGES

Zoom out image (b) Zoom out image (a)

Zoom out image ( c)

Zoom out image (d)

Zoom out image (e)

Zoom out image (f)

You might also like