Complete the code to apply a sharpening kernel to the image using convolution.
sharpen_kernel = np.array([[0, -1, 0], [-1, [1], -1], [0, -1, 0]]) sharpened_image = cv2.filter2D(image, -1, sharpen_kernel)
The center value of the sharpening kernel is usually 5 to emphasize the current pixel while subtracting neighbors.
Complete the code to convert the image to grayscale before sharpening.
gray_image = cv2.[1](image, cv2.COLOR_BGR2GRAY)cv2.cvtColor is the correct OpenCV function to convert color spaces.
Fix the error in the sharpening code by filling the correct kernel normalization value.
sharpen_kernel = np.array([[0, -1, 0], [-1, 5, -1], [0, -1, 0]]) sharpened_image = cv2.filter2D(image, -1, sharpen_kernel / [1])
Sharpening kernels are usually not normalized, so dividing by 1 keeps the kernel unchanged.
Fill both blanks to create a function that sharpens an image and returns the result.
def sharpen_image(img): kernel = np.array([[0, -1, 0], [-1, [1], -1], [0, -1, 0]]) return cv2.filter2D(img, -1, kernel * [2])
The center kernel value is 5, and multiplying by 0.5 scales the sharpening effect moderately.
Fill all three blanks to create a dictionary comprehension that maps pixel intensities to sharpened values above a threshold.
sharpened_map = {pixel: pixel * [1] for pixel in pixels if pixel [2] [3]This comprehension multiplies pixels greater than 100 by 1.5 to enhance bright areas.
