How does one convert a grayscale image to RGB in OpenCV (Python)?

前端 未结 4 1864
忘掉有多难
忘掉有多难 2020-12-08 06:15

I\'m learning image processing using OpenCV for a realtime application. I did some thresholding on an image and want to label the contours in green, but they aren\'t showing

4条回答
  •  無奈伤痛
    2020-12-08 06:30

    One you convert your image to gray-scale you cannot got back. You have gone from three channel to one, when you try to go back all three numbers will be the same. So the short answer is no you cannot go back. The reason your backtorgb function this throwing that error is because it needs to be in the format:

    CvtColor(input, output, CV_GRAY2BGR)
    

    OpenCV use BGR not RGB, so if you fix the ordering it should work, though your image will still be gray.

提交回复
热议问题