I have an 8 bit IplImage
and I want to convert it to a 24 bit IplImage
. How can I do this?
Asked
Active
Viewed 1,736 times
0

Cris Luengo
- 55,762
- 10
- 62
- 120

Pixel
- 121
- 2
- 19
-
1I just would like to reccomend you to use C++ API, and use cv::Mat data types. Easier allways. – Ander Biguri May 22 '13 at 13:00
-
18bit grayscale to 24bit RGB (3x8) or 8bit grayscale to 24bit grayscale(1x24)? – LovaBill May 22 '13 at 14:05
3 Answers
3
Assuming your gray image is in a variable called image
-
IplImage *rgbimage = cvCreateImage(/*whatever size*/, 8, 3);
cvCvtColor(image, rgbimage, CV_GRAY2BGR);

Roger Rowland
- 25,885
- 11
- 72
- 113
3
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.);

Rachel Gallen
- 27,943
- 21
- 72
- 81
2
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!

2vision2
- 4,933
- 16
- 83
- 164
-
1The cvtColor (http://docs.opencv.org/modules/imgproc/doc/miscellaneous_transformations.html#cvtcolor) function does exactly what you described, in one line. – mpenkov May 23 '13 at 05:43