Complete the code to extract the red channel from the image array.
red_channel = image[:, :, [1]]The red channel is the first channel in an RGB image, so its index is 0.
Complete the code to create a grayscale image by averaging the RGB channels.
gray_image = image.mean(axis=[1])The color channels are along axis 2 in the image array, so averaging over axis 2 converts RGB to grayscale.
Fix the error in the code to swap the red and blue channels of the image.
swapped_image = image[:, :, [[1], 1, 0]]
The red channel is at index 0 and blue at index 2, so swapping means placing blue first (2), then green (1), then red (0).
Fill both blanks to create a new image with only the green channel and zeros for red and blue.
new_image = np.zeros_like(image) new_image[:, :, [1]] = image[:, :, [2]]
The green channel is at index 1, so we copy the green channel from the original image to the green channel of the new image.
Fill all three blanks to normalize each color channel separately to the range 0-1.
normalized = np.empty_like(image, dtype=float) for i in range(3): channel = image[:, :, [1]] min_val = channel.min() max_val = channel.max() normalized[:, :, [2]] = (channel - min_val) / (max_val - min_val) result = normalized[:, :, [3]]
We loop over each channel index i, extract that channel, normalize it, and assign it back to the same channel index i. Finally, we select channel i from the normalized image.