Example of Python opencv reading RGB channel graph


I will not say much nonsense, directly on the code!

The core class in opencv is matrix, which is the abbreviation of matrix and represents matrix. This class is in the header file opencv2 / core\ core.hpp It contains a lot of basic matrix operations, C + + need to reference
Python contains numpy, so you don't need to use mat '' '
#The image storage mode in opencv is (h, W, channel), and the order is BGR
import cv2
import sys
if __name__=='__main__':
  if len(sys.argv)>1:
    b=img[:, :, 0]
    g=img[:, :, 1]
    r=img[:, :, 2]
    cv2.imshow('img', img)
    cv2.imshow('G', g)
    cv2.imshow('R', r)
    print 'can not open the image'

Call::~/PycharmProjects/OpenCV$ python show_RGB.py timg.jpeg

The above example of Python opencv reading RGB channel diagram is the whole content shared by Xiaobian. I hope to give you a reference, and also hope that you can support developeppaer more.