split_merge

split将(矩阵或者向量)按通道分开,merge反之;

split:
Copies each plane of a multi-channel matrix into an array.
C++: void gpu::split(const GpuMat& src, GpuMat* dst, Stream& stream=Stream::Null())
C++: void gpu::split(const GpuMat& src, vector& dst, Stream& stream=Stream::Null())
Parameters:
src – Source matrix.
dst – Destination array/vector of single-channel matrices.//有数组和容器两种形式
stream – Stream for the asynchronous version.

merge:
Makes a multi-channel matrix out of several single-channel matrices.
C++: void gpu::merge(const GpuMat* src, size_t n, GpuMat& dst, Stream& stream=Stream::Null())
C++: void gpu::merge(const vector& src, GpuMat& dst, Stream& stream=Stream::Null())
Parameters:
src – Array/vector of source matrices. //数组和容器两种形式
n – Number of source matrices.// 使用数组时指定原文件数量
dst – Destination matrix.
stream – Stream for the asynchronous version.

例:

#include <QCoreApplication>
#include <opencv2/opencv.hpp>

int main(int argc, char *argv[])
{
    //QCoreApplication a(argc, argv);
    cv::Mat image = cv::imread("E:/image/images/opencv-logo.png");
   // cv::Mat dst[3]; //mat数组
    cv::vector<cv::Mat> dst; //mat 容器

   cv::Mat merge;
    cv::split(image,dst); // dst 为数组与容器均可

    //cv::merge(dst,3,merge); //dst为数组
    cv::merge(dst,merge); //dst为容器


    cv::imshow("show",image);
    cv::imshow("1",dst[0]);
    cv::imshow("2",dst[1]);
    cv::imshow("3",dst[2]);
    cv::imshow("merge",merge);
    cv::waitKey();

    //return a.exec();
}

其中

// cv::Mat dst[3]; //函数原型中声明为 GpuMat* dst
    cv::vector<cv::Mat> dst; //原型vector<GpuMat>& dst
    //还可以用std::vector
    cv::vector<cv::Mat> dst;

定义方式与使用应牢记

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值