Tuesday , March 19 2024

Visualizing the Different Color Channels of an RGB Image in Python using OpenCV

9 Visualizing the different color channels of an RGB image.

Visualizing the Different Color Channels of an RGB Image in Python using OpenCV

In [2]:
import cv2
img = cv2.imread('ocv2.png',1)
cv2.imshow('Machine Learning',img)
cv2.waitKey(0)
cv2.destroyAllWindows()

In [3]:
import cv2 
img=cv2.imread("ocv2.png",1)
B, G, R = cv2.split(img) 
print(B)
print(G)
print(R)
[[255 255 255 ... 255 255 255]
 [255 255 255 ... 255 255 255]
 [255 255 255 ... 255 255 255]
 ...
 [255 255 255 ... 255 255 255]
 [255 255 255 ... 255 255 255]
 [255 255 255 ... 255 255 255]]
[[255 255 255 ... 255 255 255]
 [255 255 255 ... 255 255 255]
 [255 255 255 ... 255 255 255]
 ...
 [255 255 255 ... 255 255 255]
 [255 255 255 ... 255 255 255]
 [255 255 255 ... 255 255 255]]
[[255 255 255 ... 255 255 255]
 [255 255 255 ... 255 255 255]
 [255 255 255 ... 255 255 255]
 ...
 [255 255 255 ... 255 255 255]
 [255 255 255 ... 255 255 255]
 [255 255 255 ... 255 255 255]]
In [4]:
cv2.imshow("original", img) 
cv2.waitKey(0) 
cv2.destroyAllWindows()

In [5]:
cv2.imshow("blue", B) 
cv2.waitKey(0) 
cv2.destroyAllWindows()

In [6]:
cv2.imshow("Green", G) 
cv2.waitKey(0) 
cv2.destroyAllWindows()

In [7]:
cv2.imshow("red", R) 
cv2.waitKey(0) 
cv2.destroyAllWindows()

About Machine Learning

Check Also

Record Video From a Webcam using OpenCV

12 Record Video using OpenCV Record Video From a Webcam using OpenCV¶ cv2.VideoWriter( filename, fourcc, …

Leave a Reply

Your email address will not be published. Required fields are marked *