Solve in python please
Constraints:
Do not import/use any Python modules except for copy
(see part D hints).
Do not alter the transform_image or big_end_to_int
functions in the hw06.py template.
Do not change the function names or
arguments.
Follow the instructions in the hw06.py
template.
Your submission should have no code outside of the
function definitions aside from comments and import
statements.
You are permitted to write helper functions outside of
the ones provided in the template.
You are not required to submit any of the .bmp files to
Gradescope: only the hw06.py file will be graded.
Next, you will be implementing the grayscale
function. This converts the image to grayscale (a black and
white image). To do this, for every pixel, we must compute
the average of the components with the following
formula:
avg = (red + green + blue)/3
Once we have this value, truncate it down to the nearest
integer, and set all three components to it to get the grayscale
pixel. This means you should use the int() function, not
round().
Examples:
>>> grayscale([[[127, 127, 127], [0, 0,
0]],
[[255, 255, 0], [50, 128, 255]],
[[0, 0, 255], [0, 255, 0]],
[[255, 0, 0], [255, 255, 255]]])
[[[127, 127, 127], [0, 0, 0]],
[[170, 170, 170], [144, 144, 144]],
[[85, 85, 85], [85, 85, 85]],
[[85, 85, 85], [255, 255, 255]]]
>>> grayscale([[[36, 155, 90], [63, 208, 208],
[151, 3, 14]],
[[53, 204, 53], [99, 103, 10], [94, 138,
216]]])
[[[93, 93, 93], [159, 159, 159], [56, 56,
56]],
[[103, 103, 103], [70, 70, 70], [149, 149,
149]]]