通道融合
merge(vector<cv::Mat>& imgList)
{
int inputChannels = imgList.at(0).channels();
int outChaneels = inputChannels * imgList.size();
Mat newImg2 = cv::Mat(imgList.at(0).rows, imgList.at(0).cols, CV_MAKETYPE(imgList.at(0).depth(), imgList.size()*imgList.at(0).channels()), cv::Scalar(0));
uchar* out_ptr = newImg2.data;
#pragma omp parallel for num_threads(5)
int i, j, k, c;
for ( i=0 ; i < imgList[0].rows; i++)
{
for ( j=0 ; j < imgList[0].cols; j++)
{
for ( k=0 ; k < outChaneels / imgList[0].channels();k++)
{
cv::Mat im = imgList[k];
uchar* in_ptr = im.data;
for ( c=0; c < imgList[0].channels(); c++)
{
*(out_ptr+i*im.cols*outChaneels+j*outChaneels+c*outChaneels / imgList[0].channels()+k) = *(in_ptr + i * im.cols*im.channels()+j*im.channels() + c);
}
}
}
}
}