% Function Name: imageInterp % Inputs (3): - (uint8) An image array % - (double)
ID: 3540034 • Letter: #
Question
% Function Name: imageInterp
% Inputs (3): - (uint8) An image array
% - (double) The new number of rows the image should have
% - (double) The new number of columns the image should have
% Output (1): - (uint8) A resized image using interpolation
%
% Function Description:
% Write a function called "imageInterp" that takes in an image array and
% the new dimensions of the images and scales the image using
% interpolation. Scaling using interpolation results in clearer images
% when resizing versus traditional techniques.
%
% To scale an image with interpolation, the function first scales the
% width of the image to the new column amount. This can be accomplished by
% iterating through each row of image and using the interp() function to
% find the new pixel values. The interp() function takes in a vector of
% x-values, a vector of corresponding y-values, and a vector of new
% x-values within the same range as the original, and gives back what the
% probable new y-values would be if there was a linear relationship
% between the data sets. For additional information, please type 'help
% interp' in the Command Window.
%
% When performing the linear interpolation, the x-values are taken to be
% the column indices of the image, and the y-values are the current values
% at a layer. The new x-values are then the indices found using the
% conventional re-indexing formula taught in class, except that the
% round() is not applied. Essentially, the new x-values should equal the
% linspace(1, col, new_col). After all the rows are scaled, the image has
% been scaled to the given width. The same process is then repeated except
% we now loop through the columns and use the row indices as the
% x-values, completing the resizing of the image.
%
% Test Cases:
% img = imread('sample.png');
% new_img = imageInterp(img, 400, 400);
% imshow(new_img)
% => Should look like imageInterp1.png
%
% img = imread('buzz.png');
% new_img = imageInterp(img, round(336*1.4), round(445*1.4));
% imshow(new_img)
% => Should look like imageInterp2.png
Explanation / Answer
i am sending the answer wait
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.