Ask Your Question
1

How does opencv convert a bgr image to greyscale?

asked 2016-02-04 05:15:56 -0600

RVQ gravatar image

Hi,

I have a simple question. I read about the cvtColor function in the docs. I would like to know how OpenCV converts a BGR image to greyscale image.

According to the docs it uses the following formular.

formular

Is it correct, that the Y stands for the alpha channel and all values in this channel will be replaced by 0.299?

Thanks in advance!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2016-02-04 05:39:55 -0600

berak gravatar image

updated 2016-02-04 05:40:52 -0600

the Y stands for the grayscale pixel value, not for alpha (which is irrelevant for computer vision, and thus just gets discarded)

the formula is actually a weighted sum,

gray = (0.299 * red) + (0.587 * green) + (0.114 * blue).

maybe it gets more obvious, if you just add up the factors:

0.299 + 0.587 + 0.114 = 1

edit flag offensive delete link more

Comments

Thank you for clarification!

RVQ gravatar imageRVQ ( 2016-02-04 06:01:05 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-02-04 05:15:56 -0600

Seen: 475 times

Last updated: Feb 04 '16