Last active
March 24, 2017 14:11
-
-
Save StevenPuttemans/f672274f0868c8dc1885 to your computer and use it in GitHub Desktop.
[OPENCV3.2] Efficiently merge single channels into multi channel matrix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Approach 1 | |
Mat result_channel(rows, cols, CV_8UC3); | |
Mat in[] = { blue_channel, green_channel, red_channel }; | |
int from_to[] = { 0,0, 1,1, 2,2 }; | |
mixChannels( in, 3, &result_channel, 1, from_to, 3 ); | |
// Approach 2 | |
blue_channel.copyTo( result_channel( Rect(0, 0, cols, rows) ) ); | |
green_channel.copyTo( result_channel( Rect(cols, 0, cols, rows) ) ); | |
red_channel.copyTo( result_channel( Rect(cols*2, 0, cols, rows) ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment