Ask Your Question
0

Problem with Red And Blue

asked Feb 28 '18

cjacquel gravatar image

Hello,

When I save my images, they look like to have a lot of blue component.

Do OpenCV use BGR or RGB for saving or processing images ?

How to switch from one to another ?

Thank you, cjacquel

Preview: (hide)

1 answer

Sort by » oldest newest most voted
2

answered Feb 28 '18

LBerger gravatar image

updated Feb 28 '18

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.

Preview: (hide)

Question Tools

1 follower

Stats

Asked: Feb 28 '18

Seen: 1,108 times

Last updated: Feb 28 '18