Question: Code: function [OutIm_Bilinear, OutIm_Nearest] = ImZoomShrink(InIm, new_row, new_col) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Image Processing Class Assignment 1 % % Image Interpolation % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Input: % InIm
![Code: function [OutIm_Bilinear, OutIm_Nearest] = ImZoomShrink(InIm, new_row, new_col) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Image](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/10/6706ac43753a5_5626706ac42e5190.jpg)
Code:
function [OutIm_Bilinear, OutIm_Nearest] = ImZoomShrink(InIm, new_row, new_col)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Image Processing Class Assignment 1 % % Image Interpolation % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Input: % InIm - input image (gray level 8 bits) % new_col - number of columns of output image; % new_row - number of rows of output image; % % Output: % OutIm_Bilinear - output image (new_row*new_col) computed using bilinear method; % OutIm_Nearest - output image (new_row*new_col) computed using nearest method;
%%%%%%%%%%%%%%%%
% get the size of input image [old_row, old_col] = size(InIm); % compute zoom_factors (zoom_row and zoom_col); zoom_row = new_row/old_row; zoom_col = new_col/old_col; % Initialize two output images to black; OutIm_Bilinear=uint8(zeros(new_row, new_col)); OutIm_Nearest=uint8(zeros(new_row, new_col));
% Hints: % 1. Two for loops should be used to compute the corresponding % coordinates in the input image for every pixel in the output image . % If a corresponding coordinate (x or y) is smaller than one, set it to 1. % % 2. You may use round, ceil, and floor operators to find neighboring pixels % (type 'help round', 'help ceil', and 'help floor' in Matlab Command Window % to see help information). % % 3. You can test your function as below in Matlab Command Window: % % clear all % close all % lena=imread('lena.bmp') % assume lena.bmp is in the current directory % [OutIm_Bilinear, OutIm_Nearest] = ImZoomShrink(lena, 150, 150); % figure(1), imshow(OutIm_Bilinear); % figure(2), imshow(OutIm_Nearest); % [OutIm_Bilinear, OutIm_Nearest] = ImZoomShrink(lena, 750, 750); % figure(3), imshow(OutIm_Bilinear); % figure(4), imshow(OutIm_Nearest); % [OutIm_Bilinear, OutIm_Nearest] = ImZoomShrink(lena, 500, 750); % figure(5), imshow(OutIm_Bilinear); % figure(6), imshow(OutIm_Nearest); % [OutIm_Bilinear, OutIm_Nearest] = ImZoomShrink(lena, 750, 500); % figure(7), imshow(OutIm_Bilinear); % figure(8), imshow(OutIm_Nearest);
for i = 1:new_row for j = 1:new_col x = i/zoom_row; y = j/zoom_col; if x
lena.bmp:

Please complete the provided Matlab code to implement Nearest Interpolation method and Bilinear Interpolation method. You may use lena.bmp (256 256) to test your program and run your program using the following input parameters: Outlm_Bilinear, Outim_Nearest]-ImZoomShrink(lena, 150, 150); [Outlm_Bilinear, Outlm_Nearest]-ImZoomShrink(lena, 750, 750); Outlm_Bilinear, Outlm_Nearest]-ImZoomShrink(lena, 500, 750); Outlm_Bilinear, Outlm_Nearest]-ImZoomShrink(lena, 750, 500); Please compare the output images generated by bilinear and nearest methods. You may use round, ceil, and floor operators to find neighboring pixels (type 'help round', 'help ceil', and help floor' in Matlab Command Window to see help information) Please complete the provided Matlab code to implement Nearest Interpolation method and Bilinear Interpolation method. You may use lena.bmp (256 256) to test your program and run your program using the following input parameters: Outlm_Bilinear, Outim_Nearest]-ImZoomShrink(lena, 150, 150); [Outlm_Bilinear, Outlm_Nearest]-ImZoomShrink(lena, 750, 750); Outlm_Bilinear, Outlm_Nearest]-ImZoomShrink(lena, 500, 750); Outlm_Bilinear, Outlm_Nearest]-ImZoomShrink(lena, 750, 500); Please compare the output images generated by bilinear and nearest methods. You may use round, ceil, and floor operators to find neighboring pixels (type 'help round', 'help ceil', and help floor' in Matlab Command Window to see help information)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
