Creating a 4D matrix with one 3 channel frame and another 1 channel frame

it is not “4D”, it is “4-channel”. a 4-channel picture has 3 dimensions: height, width, channel.