OpenCV is down with B,G,R
Images contain a large amount of spatially related intensity data. Most commercial off the self (COTS) cameras today contain CMOS sensors. These sensors are arrays of silicon detectors commonly arranged in an orientation known as a Bayer filter. This filter arrangements consists of 2 green detectors, 1 blue, and 1 red for each pixel of the image. These channels are often referred to as RGB. The cameras internal algorithems are used to encode, decode, and store this information on some type of memory card.
Python can be used to read and manipulate image data for feature extraction. OpenCV is a popular library that has its basis in the Cplusplus community, and is now available as the
cv2 python module. You can install it on Mac using
brew install opencv.
To read an image and get access to the intensities stored with RGB channel you can use opencv as follows,
# load the opencv module import cv2 # read an image from the local file system img = cv2.imread('location/to/image.jpg', 1) # split the image into its blue, green, and red channel intensities # Note: the order of channels is b,g,r in opencv. NOT r,g,b. b, g, r = cv2.split(img) # show the blue channel grey level intensity cv2.imshow('blue', b) # wait for the 0 key to close image cv2.waitKey(0)
Note: the order of channels is b,g,r in opencv. NOT r,g,b as is usually the way it is referred. Some just have to go against the grain.