今天學習了c++ opencv 分離通道的方法 ,操作很奇怪的...
Mat bgr_res[3];
Mat bgr[3];
for( int j = 0 ; j < 3; j++)
{
split(src, bgr);
for (int i=0; i<3; ++i)
{
if (i != j )
bgr[i] = Mat::zeros(src.size(), bgr[0].type());
}
merge(bgr, 3, bgr_res[j]);
}
merge:
Composes a multi-channel array from several single-channel arrays.
Parameters: |
|
---|
The functions mergemerge 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 asmv[i].channels()-element vectors.
The functionsplit() does the reverse operation. If you need to shuffle channels in some other advanced way, usemixChannels() .
附上程序運行的結果:還是挺有意思的:
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。