2019-02-03 18:34:53 +03:00
|
|
|
from .helper import PillowTestCase, hopper
|
2012-10-16 00:26:38 +04:00
|
|
|
|
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
class TestImageHistogram(PillowTestCase):
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
def test_histogram(self):
|
2012-10-16 00:26:38 +04:00
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
def histogram(mode):
|
2014-09-05 14:03:56 +04:00
|
|
|
h = hopper(mode).histogram()
|
2014-06-10 13:10:47 +04:00
|
|
|
return len(h), min(h), max(h)
|
|
|
|
|
2014-09-14 21:00:13 +04:00
|
|
|
self.assertEqual(histogram("1"), (256, 0, 10994))
|
|
|
|
self.assertEqual(histogram("L"), (256, 0, 638))
|
2019-06-11 12:28:31 +03:00
|
|
|
self.assertEqual(histogram("I"), (256, 0, 638))
|
2014-09-14 21:00:13 +04:00
|
|
|
self.assertEqual(histogram("F"), (256, 0, 638))
|
|
|
|
self.assertEqual(histogram("P"), (256, 0, 1871))
|
|
|
|
self.assertEqual(histogram("RGB"), (768, 4, 675))
|
2014-06-10 13:10:47 +04:00
|
|
|
self.assertEqual(histogram("RGBA"), (1024, 0, 16384))
|
|
|
|
self.assertEqual(histogram("CMYK"), (1024, 0, 16384))
|
2014-09-14 21:00:13 +04:00
|
|
|
self.assertEqual(histogram("YCbCr"), (768, 0, 1908))
|