I recently came across a new package nicematrix
that seems to solve most of the common problems that a normal user encounters when trying to setup a simple table. From the manual:
In the environments of nicematrix, it’s possible to use the command
\Block
in order to place an element in the center of a rectangle of
merged cells of the array.
The command \Block
don’t create space by itself. The command
\Block
must be used in the upper leftmost cell of the array with two
arguments.
The first argument is the size of the block with the syntax i-j where
i is the number of rows of the block and j its number of columns. The
second argument is the content of the block.
In NiceTabular
the content of the block is composed in text mode.
In the other environments, it is composed in math mode
The "[hvlines]" keyword further simplifies typing.
The resulting code is quite compact, without the need for new commands or added packages.
\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\NiceMatrixOptions{cell-space-top-limit = 3pt,cell-space-bottom-limit = 2pt}
\begin{NiceTabular}{r*{12}{c}}[hvlines]
\Block{2-1}{channels}& \Block{1-12}{Encoding format} \\
& \Block{1-12}{pixel} \\
1 & \Block{1-12}{grey} \\
2 & \Block{1-6}{grey} &&&&&& \Block{1-6}{alpha}&&&&&\\
3 & \Block{1-4}{R} &&&& \Block{1-4}{G} &&&& \Block{1-4}{B} &&&\\
4 & \Block{1-3}{R}&&&\Block{1-3}{G} &&& \Block{1-3}{B} &&& \Block{1-3}{A}&&\\
\end{NiceTabular}
\end{document}

This is the first time I have tried it. I used one of the many examples included in the document as a guide.
https://ctan.org/pkg/nicematrix?lang=en