Fredrik Lundh is sharing code with you

Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.

Don't show this again

effbot / pil-2009-raclette http://effbot.org/zone/pil-index.htm

Work repository for PIL 1.1.7 and beyond. The "default" branch should be fairly solid, the other branches less so. For production use, see the pil-117 repository.

Clone this repository (size: 1.6 MB): HTTPS / SSH
hg clone https://bitbucket.org/effbot/pil-2009-raclette
hg clone ssh://hg@bitbucket.org/effbot/pil-2009-raclette

pil-2009-raclette / Tests / test_image_histogram.py

from tester import *

from PIL import Image

def test_histogram():

    def histogram(mode):
        h = lena(mode).histogram()
        return len(h), min(h), max(h)

    assert_equal(histogram("1"), (256, 0, 8872))
    assert_equal(histogram("L"), (256, 0, 199))
    assert_equal(histogram("I"), (256, 0, 199))
    assert_equal(histogram("F"), (256, 0, 199))
    assert_equal(histogram("P"), (256, 0, 2912))
    assert_equal(histogram("RGB"), (768, 0, 285))
    assert_equal(histogram("RGBA"), (1024, 0, 16384))
    assert_equal(histogram("CMYK"), (1024, 0, 16384))
    assert_equal(histogram("YCbCr"), (768, 0, 741))