SoFunction
Updated on 2024-11-21

Python-openCV read RGB channel map example

I'll cut to the chase and get right to the code!

#coding=utf-8
'''The core class in openCV is Mat, he is the abbreviation of matrix stands for matrix, the class is in the header file opencv2\core\, it contains a lot of basic matrix operations, C++ need to be referenced!
Python contains numpy, in Python do not need to use Mat '''
#openCV image storage is (h,w,channel), order is BGR
import cv2
import sys
if __name__=='__main__':
  if len()>1:
    img=([1],cv2.CV_LOAD_IMAGE_UNCHANGED)
    b=img[:, :, 0]
    g=img[:, :, 1]
    r=img[:, :, 2]
    ('img', img)
    ('B',b)
    ('G', g)
    ('R', r)
    (0)
    ()
  else:
    print 'can not open the image'

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

The above example of this Python-openCV read RGB channel map is all that I have shared with you.