How to make OpenCv show an image in combination of two color channels?

后端 未结 1 1911
[愿得一人]
[愿得一人] 2021-01-25 16:16

It\'s not that difficult to use OpenCV to get an output of one colour channel from an image and that can be easily done.

But is it possible that from the three main BGR

相关标签:
1条回答
  • 2021-01-25 16:22

    I guess one thing you could do is hold the channels separately and combine what you want for viewing:

    #!/usr/local/bin/python3
    
    import numpy as np
    import cv2
    
    im    = cv2.imread('sd71Z.jpg')
    b,g,r = cv2.split(im)
    zeros = np.zeros_like(b)
    
    cv2.imshow("Zero blue",  cv2.merge([zeros,g,r]))
    cv2.imshow("Zero green", cv2.merge([b,zeros,r]))
    cv2.imshow('Zero red',   cv2.merge([b,g,zeros]))
    cv2.waitKey()
    

    0 讨论(0)
提交回复
热议问题