Convert single channle image to 3 channel image C++ / OpenCV

Viewed 48206

Im using openCV C++

Im need to convert a single channel image to 3 channels image. So i can use this: cvCvtColor(result,gray,CV_BGR2GRAY);

I cannot do that because the result img is a single channel image. Any ideas?

6 Answers

You can create a vector of the same channel, then merge them, like as follows:

std::vector<cv::Mat> copies{mat,mat,mat};  
cv::merge(copies,mat);
Related