Assuming your gray image is in a variable called image
-
IplImage *rgbimage = cvCreateImage(/*whatever size*/, 8, 3);
cvCvtColor(image, rgbimage, CV_GRAY2BGR);
Pregunta
I have an 8 bit IplImage
and I want to convert it to a 24 bit IplImage
. How can I do this?
Solución
Assuming your gray image is in a variable called image
-
IplImage *rgbimage = cvCreateImage(/*whatever size*/, 8, 3);
cvCvtColor(image, rgbimage, CV_GRAY2BGR);
Otros consejos
You need cvConvertScale this is an example from this question
IplImage *im8 = cvLoadImage(argv[1]);
IplImage *im32 = cvCreateImage(cvSize(im8->width, im8->height), 32, 3);
cvConvertScale(im8, im32, 1/255.);
Here you go,
Mat input_8Bit;
vector <Mat> Vec_temp_8bit;
Vec_temp_8bit.push_back ( input_8Bit );
Vec_temp_8bit.push_back ( input_8Bit );
Vec_temp_8bit.push_back ( input_8Bit );
Mat Output_24Bit;
merge ( Vec_temp_8bit, Output_24Bit );
Please give a try, I havent checked it. But logically it should work!