Arkerone Arkerone - 6 months ago 40
C++ Question

OpenCV how to imwrite a RGB image

How do I write a

image with the function
? So far all my attempts lead into writing a
image instead.

My matrix object is a


The cv::imwrite() function correctly writes an image file if the input cv::Matis in BGR order (which is the case if you let OpenCV create it). If you created the image by yourself, you have to convert the color ordering before, for example by calling as suggested by bamboove cv::cvtColor(in, out, CV_RGB2BGR); if you created an RGB image.

(Pay attention to the color conversion code, it's slightly different from bamboon's.)