a) Write a function called image_crop that takes in two parameters – an image and an array representing the size and position of the crop rectangle in spatial coordinates. The array should be...

a) Write a function called image_crop that takes in two parameters – an image and an array representing the size and position of the crop rectangle in spatial coordinates. The array should be specified as a four-element numeric vector in the form of [xmin ymin width height] where xmin and ymin are the spatial coordinates of the starting point of the crop box. Assume that the elements in this array are always positive integers. Figure 1a illustrates the definition of each value assuming it is used to crop out the penguin in the given image. Figure 1b returns the results of the function. If the height and the width passed to the function or when the result of adding the starting point coordinates with the given height and width exceeds the max size of the image, the function should print an error message (EM1): "Size of image is 800 x 1000. Attempting to crop beyond size of image." The values of 800 and 1000 in the error message should change according to the size of the image passed to the function. If xmin and ymin passed to the function exceeds the array dimensions, the function should print an error message (EM2): "Starting point is out of bounds. xmin must be between 1 to 1000. ymin must be between 1 to 800." The values of 800 and 1000 in the error message should change according to the size of the image passed to the function. You must use the error() function for this question. Take a look at the documentation for the error function using by typing help error in the command window if you do not know how to use this function. Important: You cannot use MATLAB imcrop() function for this question.
May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here