Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cvtColor won't do any depth conversion here:

Mat raw_image(600, 800, CV_16UC1, buffer.data());
cvtColor(raw_image, rgb_image, CV_BayerBG2BGR);

so if your raw input image is CV_16U, the resulting bgr image will have exactly the same depth

then, imread(raw_path) will silently convert to 8bit bgr (i guess, the confusion comes from there !),

if you want to keep the original depth (and assuming you saved it with a .png extension), use

imread(raw_path, IMREAD_ANYDEPTH);

cvtColor won't do any depth conversion here:

Mat raw_image(600, 800, CV_16UC1, buffer.data());
cvtColor(raw_image, rgb_image, CV_BayerBG2BGR);

so if your raw input image is CV_16U, the resulting bgr image will have exactly the same depth

then, imread(raw_path) will silently convert to 8bit bgr (i guess, the confusion comes from there !),

if you want to keep the original depth (and assuming you saved it with a .png extension), use

imread(raw_path, IMREAD_ANYDEPTH);

if you need the result to be 8bit, you will have to convert it manually:

Mat bgr8;
rgb_image.convertTo(bgr8, CV_8U, 1.0/255);