0% found this document useful (0 votes)
187 views5 pages

Wa0014.

This document is a lab assignment submitted by a student named Nabila Nowshin to their lecturer for their Computer Vision and Image Processing course. The assignment involves writing code to implement pixel replication or nearest neighbor interpolation to zoom in on an image. The code provided takes in an image, allows the user to enter a zoom factor, initializes a new larger output image with zeros, and then uses nested for loops to copy pixel values from the original image into the corresponding locations in the zoomed image. It displays both the original and zoomed images with titles indicating the zoom factor.

Uploaded by

Nadia Nitu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
187 views5 pages

Wa0014.

This document is a lab assignment submitted by a student named Nabila Nowshin to their lecturer for their Computer Vision and Image Processing course. The assignment involves writing code to implement pixel replication or nearest neighbor interpolation to zoom in on an image. The code provided takes in an image, allows the user to enter a zoom factor, initializes a new larger output image with zeros, and then uses nested for loops to copy pixel values from the original image into the corresponding locations in the zoomed image. It displays both the original and zoomed images with titles indicating the zoom factor.

Uploaded by

Nadia Nitu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Uttara University

Lab Assignment 2
Course Title: Computer Vission and image processing and sessional
Course Code: CSEC467

Submitted To:
Name: Md.Harun-Ar-Rashid
Lecturer
Department of Computer Science & Engineering
Uttara University
Submitted by:
Name: Nabila Nowshin
ID: 2201081072
Batch: 50 B
Department of Computer
Science
& Engineering
Uttara University
Submission Date:05/03/2023
Pixel Replication or(Nearest Neighbour interpolation) Code:

clc; [clear the command window] clear all;


[clears all variables in the workspace ] close
all; [close all open Figure ]

img = imread('elham.jpg'); [reads in the image 'elham.jpg' and


stores it in the variable img]

% Check the number of dimensions of the input image


if ndims(img) == 3
[m,n,~] = size(img);
else
[m,n] = size(img); end

Z = input('Enter the Zooming Factor = ');

% Initialize the output image with zeros


A = zeros(m*Z, n*Z, 'uint8'); [initializes a new image matrix with
zeros, scaled by the zooming factor, with data type 'uint8']

for i = 1:m [1st dimension of input img where it is going to extract


each and every row of the img]
for j = 1:n [next input of dimension img that extract each and every
coloum of the img]
for k = 1:Z [ loops through each zoomed-in pixel in the new
image]
A((i-1)*Z+k,(j-1)*Z+k) = img(i,j); [assigns the value of the
original pixel to the corresponding zoomed-in pixel] end
end end

% Display the images


imshow(img),title('Original Image'); [displays the original image with
a title] figure; [creats a figure ]
imshow(A),title(sprintf('Zoomed Image (Zooming Factor = %g)', Z));
[displays the zoomed image with a title that includes the zooming
factor]

You might also like