Files
open-cv-experiment/test/2024,9,10/main.py
T

30 lines
604 B
Python

import cv2 as cv
# read image
img = cv.imread("opencv_logo.png",cv.IMREAD_UNCHANGED)
# get height and width, channel of img
height,width,channel=img.shape
# show infos
print(img.shape)
print("height=\t",height)
print("width=\t",width)
print("channel=\t",channel)
# split channels
blue,green,red=cv.split(img)
# show channels
## red channel
cv.namedWindow("red channel")
cv.imshow("red channel", red)
## green channel
cv.namedWindow("green channel")
cv.imshow("green channel", green)
## blue channel
cv.namedWindow("blue channel")
cv.imshow("blue channel", blue)
cv.waitKey(0)
cv.destroyAllWindows()