我有两个我要融合的视频。我计划拍摄可见光视频,捕捉帧,并将帧转换为YUV。在将其与IR视频融合之前,我想提取Y分量,将其放入相同大小的Mat类型的另一个图像(变量)中并与IR帧的亮度融合。融合后,我想把Cb和Cr放回来获得颜色。
我看到了这个链接:Getting the Y and Cb , Cr values of a frame in openCV c++
但我无法弄清楚如何用这种提取Y,Cb和Cr的方法创建自己的矩阵。
我有什么想法可以做到这一点?
答案 0 :(得分:3)
查看split()和merge
Mat vis_img; // from cam
Mat ycrcb;
cvtColor( vis_img, ycrcb, CV_BGR2YCRCB ); // am i right assuming rgb input even ?
Mat channels[3];
split( ycrcb, channels );
// y is channels[0], cb is channels[1], cr, well...
// some operations on channels later..
// once you 'fused' your luminance channels into one, you can re-assemble the image
// from the channels:
Mat new_channels[3] = { lum_fused, channels[1], channels[2] };
Mat new_ycrcb;
merge( new_channels, new_ycrcb, 3 );