Return most frequent color and its usage ratio.
(self, clip=None)
| 13583 | return rc |
| 13584 | |
| 13585 | def color_topusage(self, clip=None): |
| 13586 | """Return most frequent color and its usage ratio.""" |
| 13587 | allpixels = 0 |
| 13588 | cnt = 0 |
| 13589 | if clip is not None and self.irect in Rect(clip): |
| 13590 | clip = self.irect |
| 13591 | for pixel, count in self.color_count(colors=True,clip=clip).items(): |
| 13592 | allpixels += count |
| 13593 | if count > cnt: |
| 13594 | cnt = count |
| 13595 | maxpixel = pixel |
| 13596 | if not allpixels: |
| 13597 | return (1, bytes([255] * self.n)) |
| 13598 | return (cnt / allpixels, maxpixel) |
| 13599 | |
| 13600 | @property |
| 13601 | def colorspace(self): |