Hi, I want to write a grayscale layer for my image that convert my image from rgb to gray, However, I have already processed the image and I have to operate on the tensor. My primary implementation is like the following:
(x is the image)
result = 0.299 * x[:, 0] + 0.587 * x[:, 1] + 0.114 * x[:, 2]
return result.unsqueeze(1)
Is there a simpler way or is this correct?