View the number of image channels

1. View through python

from PIL import Image
img=Image.open('E:/Apple/test/test_label/t_11.png')
# 直接就输出图像的通道数了
print(len(img.split()))

If the output result is 1, it is a single channel
insert image description here

2. View through the image properties
insert image description here
In the detailed information of the image, if the bit depth of the image is 8, it is a single channel (grayscale image), if the bit depth is 24, it is three channels, and if the bit depth is 32, it is four channels.

Guess you like

Origin blog.csdn.net/AKxiaokui/article/details/129267981