title: Get color vector from histogram maxValue
body: <p>I'm trying to compute the most common color in an image. Using <strong><em>calcHist</em></strong> function, I understand I can get an histogram whose bins in a single channel are the pixel value, and the value of each bin is how many times is that value present in the image. </p>
  
  <p>Also, it is easy to get the max value of the histogram (that is a double) and its position using <strong><em>minMaxLoc</em></strong> function. </p>
  
  <p>But what I want is the whole color (the Vec3b object with the value of each channel). </p>
  
  <p>Here's what I have so far:</p>
  
  <pre><code> split(image, lab_channels); 
  
   histSize = 256;
   range[0] = 0;
   range[1] = 256;
   const float *lRange = {range};
   calcHist( &amp;lab_channels[0], 1, 0, Mat(), 
       l_hist, 1, &amp;histSize, &amp;lRange, 
       true, false );
  
   histSize = 256;
   range[0] = 0;
   range[1] = 256;
   const float *aRange = {range};
   calcHist( &amp;lab_channels[1], 1, 0, Mat(), 
       a_hist, 1, &amp;histSize, &amp;aRange, 
       true, 
       false );
  
   histSize = 256;
   range[0] = 0;
   range[1] = 256;
  
   const float *bRange = {range};
   calcHist( &amp;lab_channels[2], 1, 0, Mat(), 
        b_hist, 1, &amp;histSize, &amp;bRange, t
        rue, false );
  
   minMaxLoc(l_hist, 0, 0, 0, &amp;maxPos);
   result[0] = maxPos.y; 
   minMaxLoc(a_hist, 0, 0, 0, &amp;maxPos);
   result[1] = maxPos.y; 
   minMaxLoc(b_hist, 0, 0, 0, &amp;maxPos);
   result[2] = maxPos.y; 
  </code></pre>
  
  <p>where <strong>result</strong> is my Vec3b vector with the most common color. </p>
  
  <p>This code works fine (it does retrieve a color), but the problem is that it gets the most common color separately from each channel and finally it's not necessarely the most common color in the combined channels.</p>
  
  <p>So, if I do this procedure, but for the 3 channels (like it's shown in opencv documentation), how can I get this Vec3b vector from the resulting histogram? or at least another data type I could cast or transform to it. </p>