我读取图像,将RGBA值推入数组中,现在我要计算某些颜色的出现次数。然而,我得到的是0.我怎么做(不转换为字符串)?相关代码段和输出:使用Python计算RGBA值
输出:
Image123.png
8820
[(138, 18, 20, 255), (138, 18, 20, 255), (138, 18, 20, 255), (138, 18, 20, 255), (138, 18, 20, 255), (138, 18, 20, 255), (138, 18, 20, 255), (138, 18, 20, 255), (138, 18, 20, 255), (138, 18, 20, 255), (138, 18, 20, 255), (138, 18, 20, 255), (138, 18, 20, 255), (138, 18, 20, 255), (138, 18, 20, 255), (138, 18, 20, 255), (138, 18, 20, 255), (138, 18, 20, 255), (138, 18, 20, 255), ......
0
0
代码:
read_pixel = []
print(filename)
read_pixel.append(pixel[image_x, image_y])
print(image_size_x*image_size_y)
print(read_pixel)
count_lte_70_1 = read_pixel.count("(138, 18, 20, 255)")
print(count_lte_70_1)
#without parenthesis
count_lte_70_2 = read_pixel.count("138, 18, 20, 255")
print(count_lte_70_2)