split


Divides a multi-channel array into several single-channel arrays.

C++: void split(const Mat& src, Mat* mvbegin)

C++: void split(InputArray m, OutputArrayOfArrays mv)

Python: cv2.split(m[, mv]) → mv

C: void cvSplit(const CvArr* src, CvArr* dst0, CvArr* dst1, CvArr* dst2, CvArr* dst3)

Python: cv.Split(src, dst0, dst1, dst2, dst3) → None

Parameters:
  • src – input multi-channel array.
  • mv – output array or vector of arrays; in the first variant of the function the number of arrays must match src.channels(); the arrays themselves are reallocated, if needed.

The functions split split a multi-channel array into separate single-channel arrays:

\"\\texttt{mv}

If you need to extract a single channel or do some other sophisticated channel permutation, use mixChannels() .


merge


Creates one multichannel array out of several single-channel ones.

C++: void merge(const Mat* mv, size_t count, OutputArray dst)

C++: void merge(InputArrayOfArrays mv, OutputArray dst)

Python: cv2.merge(mv[, dst]) → dst

C: void cvMerge(const CvArr* src0, const CvArr* src1, const CvArr* src2, const CvArr* src3, CvArr* dst)

Python: cv.Merge(src0, src1, src2, src3, dst) → None

Parameters:
  • mv – input array or vector of matrices to be merged; all the matrices in mv must have the same size and the same depth.
  • count – number of input matrices when mv is a plain C array; it must be greater than zero.
  • dst – output array of the same size and the same depth as mv[0]; The number of channels will be the total number of channels in the matrix array.

The functions merge merge several arrays to make a single multi-channel array. That is, each element of the output array will be a concatenation of the elements of the input arrays, where elements of i-th input array are treated as mv[i].channels()-element vectors.

The function split() does the reverse operation. If you need to shuffle channels in some other advanced way, use mixChannels() .


Code Example:

 

收藏 打印