From 6f24eda48a58680afa14d6035c116b6e0ef7fbc2 Mon Sep 17 00:00:00 2001 From: Hugo Date: Sun, 17 Feb 2019 15:06:29 +0200 Subject: [PATCH 1/2] Document format limitations of ImageStat.Stat.extrema and recommend more efficient Image.getextrema --- docs/reference/ImageStat.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/reference/ImageStat.rst b/docs/reference/ImageStat.rst index b8925bf8cd5..7981cb9e502 100644 --- a/docs/reference/ImageStat.rst +++ b/docs/reference/ImageStat.rst @@ -20,6 +20,14 @@ for a region of an image. Min/max values for each band in the image. + .. Note:: This relies on the :py:meth:`~PIL.Image.histogram` method, and simply + returns the low and high bins used. This is correct for images with 8 bits per + channel, but fails for other modes such as ``I`` or ``F``. Instead, use + :py:meth:`~PIL.Image.getextrema` to return per-band extrema for the image. + This is more correct and efficient because :py:meth:`~PIL.Image.getextrema` is + used by the histogram method for non-8-bit modes to return extrema to define the + bins used in the histogram. + .. py:attribute:: count Total number of pixels for each band in the image. From 7fd0a1493a8d54a2cd56e34bdeddddce8ff9b13a Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sun, 31 Mar 2019 14:36:39 +1100 Subject: [PATCH 2/2] Changed wording [ci skip] --- docs/reference/ImageStat.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/reference/ImageStat.rst b/docs/reference/ImageStat.rst index 7981cb9e502..28a884d05b5 100644 --- a/docs/reference/ImageStat.rst +++ b/docs/reference/ImageStat.rst @@ -24,9 +24,8 @@ for a region of an image. returns the low and high bins used. This is correct for images with 8 bits per channel, but fails for other modes such as ``I`` or ``F``. Instead, use :py:meth:`~PIL.Image.getextrema` to return per-band extrema for the image. - This is more correct and efficient because :py:meth:`~PIL.Image.getextrema` is - used by the histogram method for non-8-bit modes to return extrema to define the - bins used in the histogram. + This is more correct and efficient because, for non-8-bit modes, the histogram + method uses :py:meth:`~PIL.Image.getextrema` to determine the bins used. .. py:attribute:: count