Ask Your Question

Revision history [back]

You need to use BGR2GRAY unless you are sure that the image you are processing is in RGB format (usually OpenCV stores images in BGR format). The fomula for calculating grayscale which OpenCV uses assigns different weights to blue and red pixels. It is as follows (see the [[http://docs.opencv.org/master/de/d25/imgproc_color_conversions.html#color_convert_rgb_gray documentation]]:

Gray = 0.299 * Red + 0.587 * Green + 0.114 * Blue

Thus if you use RGB2GRAY on a BGR picture you will get the wrong grayscale values.