Ask Your Question
0

Problem with Red And Blue

asked 2018-02-28 08:15:19 -0600

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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2018-02-28 08:26:06 -0600

LBerger gravatar image

updated 2018-02-28 08:36:45 -0600

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.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-02-28 08:15:19 -0600

Seen: 1,060 times

Last updated: Feb 28 '18