title: Finding the max colour pixel based on the value in one channel in OpenCV
body: <p>I'm starting manipulating images with OpenCV recently.</p>
  
  <p>As far as I know, the cv::max(input1, input2, output) is used for finding the maximum BGR values of 2 images. I'd like to max within one colour channel, see the following example for 2 BGR mats (mat size 2x2):</p>
  
  <p><code>input1= [110, 100, 90, 109, 99, 89;
            111, 99, 89, 108, 98, 88]</code></p>
  
  <p><code>inout2= [97, 141, 158, 95, 138, 157;
            98, 149, 169, 97, 148, 168]</code></p>
  
  <p>I want to max only the values in the blue channel, thus I will carry to my output mat whatsoever values for the green and red channels; thus I want the result to be like this:</p>
  
  <p><code>output= [110, 100, 90, 109, 99, 89;
            111, 99, 89, 108, 98, 88]</code></p>
  
  <p>Yes it happened to be that the output mat becomes a copy of input1, but please notice that running
  <code>cv::max(input1, input2, output);</code> 
   gives</p>
  
  <p><code>output= [110, 141, 158, 109, 138, 157;
            111, 149, 169, 108, 148, 168]</code></p>
  
  <p>which somehow mixes the 2 mats channels.</p>
  
  <p>Sorry for writing this long; I just wanted to be clear. Thank you,,,</p>
  
  <p>UPDATE: I already implemented a solution using C++ for loops. Honestly they work but I'm looking for something faster and simpler, if any.</p>
  
  <p>UPDATE2: From 2 input images, I need the max value from, say the blue channel, and store it into an output with its associate green and red values.</p>