嘿,我有这么多 PIL 边界框(x,y,x1,y1)
我只想知道边界框有多少种颜色,有什么快速的方法吗?
>>> myimg = ...
>>> colors = myimg.crop((x0, y0, x1, y1)).getcolors()
According to PIL's docs getcolors "Returns an unsorted list of (count, color) tuples, where the count is the number of times the corresponding color occurs in the image".