I have a char* buffer I read from disk. I point a cvMat header at it to create a single channel greyscale image. I also have a single channel cvMat that is the alpha channel of the first Mat. I would like to debayer it to a preallocated 4 channel cvMat in the most runtime efficient way possible.
I realize I could use cvtColor(charMat, preallocated4channelMat, COLOR_BayerBG2BGRA), then split the preallocated Mat, set the 4th channel to the alpha Mat, and finally merge. In my mind this would require copying the data to a vector of Mats and then copying it back. Is there a way to copy the alpha Mat into every 4th byte of the 4channel Mat?