<s>[INST] import cv2
import numpy as np

# Create a 3 channel image
img = np.random.randint(0, 255, size=(500, 500, 3), dtype=np.uint8)

# Create a noise mask
noise_mask = np.random.randint(0, 255, size=(500, 500, 1), dtype=np.uint8)

# Apply noise to the image
img_noisy = np.maximum(img, noise_mask)

print(img_noisy.shape)
print(img_noisy.dtype)

cv2.imshow('Original Image', img)
cv2.imshow('Noise Mask', noise_mask)
cv2.imshow('Image with Noise', img_noisy)
cv2.waitKey(0)
cv2.destroyAllWindows()

In this code, you are adding a 3-channel noise mask to a 3-channel image. This results in the loss of color information in the image. How would you modify this to add a grayscale noise mask to each channel of a 3-channel image?[/INST]