Given is a greyscale 8 bit input image in the form of a pixel array (a list of pixel rows, with each row represented aga
Posted: Thu May 26, 2022 9:06 am
Given is a greyscale 8 bit input image in the form of a pixel array (a list of pixel rows, with each row represented again as a list). Every pixel contains an integer value between 0 and 255. Write a Python3 function 'computeBoxAveraging3x3 (pixel_array, image_width, image_height) which computes and returns a mean (or average, or box) filtered image. The filter response image has to use the 3x3 mean filter kernel consisting of 1's and dividing by 9. The resulting image has to contain float values. Border handling: Note that when applying the 3x3 mean kernel, the filtering procedure has to access pixels that are outside the input image. For this function simply ignore the 1 pixel boundary of the input image. We referred to this case as Borderlgnore in the lecture. We set the output pixels at the outer boundary to zero. You may assume that the Python3 function 'createInitialized Greyscale PixelArray(image_width, image_height)' is available, which creates an empty greyscale array (values 0) as a list of lists of integers. For example: Test Result image_width = 6 image_height = 5 pixel_array = [[30, 70, 20, 30, 20, 30], 0.000 0.000 0.000 0.000 0.000 0.000 0.000 31.111 34.444 30.000 28.889 0.000 0.000 28.889 32.222 32.222 28.889 0.000 0.000 33.333 36.667 32.222 24.444 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [0, 40, 60, 10, 40, 40], [30, 10, 20, 50, 20, 201, [10, 60, 30, 10, 50, 20], [40, 40, 60, 50, 0, 0] ] smoothed_image = computeBoxAveraging3x3 (pixel_array, image_width, image_height) printPixelArray (smoothed_image )