Question
Function Name: blur Inputs: 1. ( char ) The file name of the input image, including file extension Outputs: None File Outputs: 1. The output
Function Name: blur Inputs:
1. ( char) The file name of the input image, including file extension Outputs:
None
File Outputs:
1. The output image with 'blur_' appended to the beginning of the filename Banned Functions:
All image functions except imread() and imwrite() are banned for this problem.
Function Description:
Write a function called blur() that takes in an input image and outputs the same image modified with a box blur. In a box blur operation, each center pixel becomes the average of all 9 pixels around it (including itself), for every color layer. Refer to the example operation below for a 3x3 uint8 array.
30 30 30 90 90 90 -> 60 60 60
** ** ** ** 60 ** ** ** **
To determine the color values of the pixels in the output image, follow these steps:
1) Index out a 3x3 piece of the original array, where the middle pixel of the 3x3 piece corresponds to the new pixel.
2) Average the values in the 3x3 array, then set the new pixel to the average value (Do this for each layer of the image separately).
3) Repeat steps 2) and 3) for all 3x3 pieces of the image array.
There are not enough pixels in the original image to calculate the border values. Hence, the output image will have 2 fewer rows (top and bottom rows) and 2 fewer columns (far left and right columns) than the original. Write the resultant image with 'blur_' appended to the beginning of the input image filename.
Example: blur('spongebobImg.png') spongebobImg.png blur_spongebobImg.pngStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started