Skip to content

ImageStat.Stat.extrema reports 0,255 on 16 bit grey image #1606

Description

@markstock

Using python-pillow-2.6.2-2.fc21.x86_64 on 16-bit grey png images, I've noticed that ImageStat.Stat.extrema reports incorrect information.

>>> from PIL import Image
>>> im = Image.open("myimg16b.png")
>>> im.mode
'I'
>>> from PIL import ImageStat
>>> ImageStat.Stat(im).extrema
[(0, 255)]

But

$ pngtopam myimg16b.png | pamsumm -max -brief
63490

Is this fixed in newer releases?
Sample image is here: myimg16b.png

Activity

  1. radarhere commented on Dec 23, 2015

    @radarhere
    Member

    No, testing with the latest version, I get the same result.

  2. wiredfool commented on Dec 27, 2015

    @wiredfool
    Member

    There is an Image.getextrema function, which returns the per-band extrema for the image.

    This function is used by the histogram function for non 8-bit modes to return extrema to define the bins used in the histogram. The histogram is still going to return a vector length = bands*256.

    ImageStat.Stat.extrema relies on the image histogram function, and simply returns the low and high bins used. This is correct for 8 bit per channel images, but fails for anything else.

    So, ultimately, Image.getextrema is a much more efficient and correct function to use.

  3. added this to the 3.2.0 milestone on Dec 29, 2015
  4. wiredfool commented on Dec 29, 2015

    @wiredfool
    Member
    • Document the format limitations of ImageStat
    • Document the much more efficient Image.getextrema function
    • Alternately, pop a warning or clear no data on I or F images
  5. removed this from the 3.2.0 milestone on Jan 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions