OpenCV image conversion from RGB to Grayscale using imread giving poor results

前端 未结 3 1363
梦毁少年i
梦毁少年i 2021-01-01 17:49

I\'m loading a 24 Bit RGB image from a PNG file into my OpenCV application.

However loading the image as grayscale directly using imread gives a very po

3条回答
  •  天涯浪人
    2021-01-01 18:23

    The simple answer is, that openCV functions uses the BGR format. If you read in a image with imread or VideoCapture, it'll be always BGR. If you use RGB2GRAY, you interchange the blue channel with the green. The formula to get the brightness is

    y = 0.587*green + 0.299*red + 0.114*blue
    

    so if you change green and blue, this will cause an huge calculation error.

    Greets

提交回复
热议问题