title: Merging three grayscale [R, G, B] images into a single color image in opencv
body: <p>I have 3 grayscale images that I created using the split function. Now I want to regenerate the color image back. 
  I tried the following code but it did not work. The resultant image I got was still grayscale.</p>
  
  <pre><code>        cv::Mat R = cv::imread("/home/r/secret_R.png",0);
          cv::Mat G = cv::imread("/home/r/secret_G.png",0);
          cv::Mat B = cv::imread("/home/r/secret_B.png",0);
          std::vector&lt;cv::Mat&gt; array_to_merge;
          array_to_merge.push_back(R);
          array_to_merge.push_back(G);
          array_to_merge.push_back(B);
          cv::Mat color;
          cv::merge(array_to_merge, color);
  </code></pre>
  
  <p>So then I tried the cvtColor function: </p>
  
  <pre><code>        cv::Mat color_converted;
          cv::cvtColor(color, color_converted, CV_GRAY2BGR);
          cv::imwrite("/home/r/color_secret.png",color_converted);
  </code></pre>
  
  <p>But apparently, it only works for source images that have only a single channel. I passed it one of my grayscale images:</p>
  
  <pre><code>cv::cvtColor(R, color_converted, CV_GRAY2BGR);
  </code></pre>
  
  <p>But I still could not get a color image back. The resultant image was still grayscale </p>
  
  <p>What am I doing wrong ? How do I get my color image back ?</p>