opencv combined into a single channel multi-channel

int main(){
    cv::Mat m1=(cv::Mat_<int>(3,2)<<1,2,3,4,5,6);
    cv::Mat m2=(cv::Mat_<int>(3,2)<<2,4,6,8,10,12);
    cv::Mat m3=(cv::Mat_<int>(3,2)<<3,6,9,12,15,18);

    cv::Mat inm[]={m1,m2,m3};
    cv::Mat outm;
    cv::merge(inm,3,outm);  // 合并后行数和列数不变。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.
    std::cout<<outm<<std::endl;

    std::vector<cv::Mat> inm1;
    inm1.push_back(m1);
    inm1.push_back(m2);
    inm1.push_back(m3);
    cv::Mat outm1;
    cv::merge(inm1,outm1);
    std::cout<<outm1<<std::endl;
    std::cout<<"outm1.rows:"<<outm1.rows<<std::endl;
    std::cout<<outm1.rowRange(1,3)<<std::endl;
    std::cout<<"outm1.cols:"<<outm1.cols<<std::endl;
    std::cout<<outm1.colRange(0,1)<<std::endl;
    return 0;
}

Note: after the formation of the same number of new combined merge function matrix rows and columns of the input matrix.

Guess you like

Origin www.cnblogs.com/ligei/p/11487786.html