OpenCV: Different Color Spaces in Image Processing with Python | by Amit Chauhan | Jul, 2021

Preprocessing techniques for feature extraction and object detection

A photo by Author
A photo by Author
Input Image. A photo by Author

RGB (Red, Green, Blue)

Image Source
import cv2image = cv2.imread('bg1.jpg')rgb_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)r, g, b = cv2.split(rgb_image)cv2.imwrite('R.jpg',r)
cv2.imwrite('G.jpg',g)
cv2.imwrite('B.jpg',b)

HSV/HSI (Hue Saturation Value/ Intensity)

Image Source
import cv2image = cv2.imread('bg1.jpg')rgb_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
hsv_image = cv2.cvtColor(rgb_image, cv2.COLOR_RGB2HSV)
h, s, v = cv2.split(hsv_image)cv2.imwrite('H.jpg',h)
cv2.imwrite('S.jpg',s)
cv2.imwrite('V.jpg',v)

LAB (Lightness Color Channel)

Image Source
import cv2image = cv2.imread('bg1.jpg')rgb_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
lab_image = cv2.cvtColor(rgb_mean, cv2.COLOR_RGB2Lab)
L, a, b = cv2.split(lab_image)cv2.imwrite('L.jpg',L)
cv2.imwrite('b_star.jpg',b)
cv2.imwrite('a_star.jpg',a)

Related posts

Celebrating Nowruz in the Digital Age: The Intersection of Technology and Spirituality

Google Pixel 9a:Performance and Value

Google Pixel 9a: The Unsung Hero of Budget Smartphones – Why It Deserves Your Attention

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Read More