Ask Your Question

Revision history [back]

Opencv uses BGR format to store data in memory

When image is save using imwrite then channels are in good order relatively to file extension (jpg, pn, ....)

Mat img=imread("fruits.jpg",IMREAD_COLOR);
cout<<img.at<vec3b>(0,0);
imwrite("Fruitsopencv.jpg",img);

results 13,62,130 check in your favourite image editor : Blue=13 Green = 62 Red=130

Opencv uses BGR format to store data in memory

When image is save using imwrite then channels are in good order relatively to file extension (jpg, pn, png, ....)

Mat img=imread("fruits.jpg",IMREAD_COLOR);
cout<<img.at<vec3b>(0,0);
imwrite("Fruitsopencv.jpg",img);
imwrite("Fruitsopencv.png",img);

results 13,62,130 check in your favourite image editor : Blue=13 Green = 62 Red=130

Opencv uses BGR format to store data in memory

When image is save using imwrite then channels are in good order relatively to file extension (jpg, png, ....)

Mat img=imread("fruits.jpg",IMREAD_COLOR);
cout<<img.at<vec3b>(0,0);
imwrite("Fruitsopencv.png",img);

results 13,62,130 check in your favourite image editor : Blue=13 Green = 62 Red=130

In previous code i don't use cvtcolor to change bgr to rgb : when you use opencv function everything is done internally.