In the space below, write a definition for a Python function…
In the space below, write a definition for a Python function named fade. The function should take two parameters, one called img, which is a Numpy array of RGB pixel values, and dir, which is a string. The function should return a Numpy array of RGB pixel values representing a copy of img that fades to black. The parameter dir determines the direction of the fade. If the value is “vertical”, fade from top to bottom, with the bottom row of pixels being all black. If the value is “horizontal”, fade from left to right, with the right-most column being all black. Raise an error if dir has any other value. The fade should be linear. So in an 11×11 pixel image with vertical fade, the 1st row should have 100% luminance, the 2nd row 90%, the 3rd row 80%, down to 0% luminance on the bottom row.
Read Details