I have two videos which I want to fuse. I plan to take the visible light video, capture frames, and convert the frames to YUV. Before fusing this with the IR video, I want to extract the Y component, put it in another image(variable) of type Mat of the same size and fuse that with the luminance of IR frame. After fusion, I want to put the Cb and Cr back to get the colors.
I saw this link: Getting the Y and Cb , Cr values of a frame in openCV c++
But I couldn't figure out how I can create my own matrices with this method of extracting Y, Cb and Cr.
Any ideas how I can do this?
1 Answer
look at split() and 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 ); 11