);
void cv::mixChannels(
const vector<cv::Mat>& srcv, // STL-style vector of matrices
vector<cv::Mat>& dstv, // STL-style vector of target matrices
const int* fromTo, // C-style array of pairs, …from,to…
size_t n_pairs // Number of pairs in ‘fromTo’
);
There are many operations in OpenCV that are special cases of the general problem of rearranging channels
from one or more images in the input, and sorting them into particular channels in one or more images in
the output. Functions like cv::split(), cv::merge(), and (at least some cases of)
cv::cvtColor() all make use of such functionality. Those methods do what they need to do by calling
the much more general cv::mixChannels(). This function allows you to supply multiple arrays, each
with potentially multiple channels, for the input, and the same for the output, and to map the channels from
the input arrays into the channels in the output arrays in any manner you choose.
The input and output arrays can either be specified as C-style arrays of cv::Mat objects with an
accompanying integer indicating the number of cv::Mats, or as an STL vector<> of cv::Mat
objects. Output arrays must be pre-allocated with their size and number of dimensions matching those of
the input arrays.
Figure 3-3: A single four-channel RGBA image is converted to one BGR and one Alpha-only image.
The mapping is controlled by