0

I know that in python (with opencv) an image is encoded with a matrix of integers.

If the image is black and white all information is inside a matrix HeightxWidth, where the int in position (i,j) gives the nuance of gray of the (i,j) th pixel.

When the image is colored, the colors are decomposed in three coordinates in the space of colors, hence all information is stored in a matrix HeightxWidthx3, because each pixel need 3 coordinate.

My question is how to convert given black-white image in BGR format, that is the format mainly used by opencv.

Thank you

Francesco

  • 2
    First, OpenCV uses BGR and not GBR. Second, What are you trying to do? `cv2.cvtColor(gray,cv2.COLOR_GRAY2BGR)` technically exists, but all it does is duplicate the gray values and stacking them to create a BGR image with identical channels. If you are trying to recover the original values, then that is a whole different game. – GaiusJulius Jul 29 '21 at 09:20
  • 2
    @GaiusJulius I think that's all that TS asked, nothin more to add – Yaroslav Kornachevskyi Jul 29 '21 at 10:00

0 Answers0