我讀取圖像,將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)