New to C++, how do you use a LUT on a 3 channel image?

I’m trying to convert a color image to greyscale using the channel averaging method. According to the docs, the fastest way to do it is using a lookup table.

I’m learning C++ and coming from Python. I’m not sure how to set up the LUT to perform the conversion. The tutorial shows using a CV_8U matrix, but wouldn’t it need to be CV_8UC3? Would the dims be 3 dimensions, or should I just use a single 1D matrix with 256^3 elements?