How do I write a RGB image with the function cv::imwrite()? So far all my attempts lead into writing a BGR image instead.
My matrix object is a cv::Mat.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
cv::imwrite()function correctly writes an image file if the inputcv::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 bamboovecv::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.)