1

嘿,我有这么多 PIL 边界框(x,y,x1,y1)

我只想知道边界框有多少种颜色,有什么快速的方法吗?

4

1 回答 1

2
>>> 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".

于 2010-10-23T15:41:06.267 回答