Sindbad~EG File Manager
�
&ٜg� � �H � d dl mZ d dlZd dlmZ ddlmZ G d� d� ZeZy)� )�annotationsN)�cached_property� )�Imagec �� � e Zd Z d d
d�Zedd�� Zedd�� Zedd�� Zedd�� Zedd�� Z edd�� Z
edd �� Zedd
�� Zedd�� Z
y)�StatNc � � t |t j � r|j |� | _ n%t |t � r|| _ n
d}t |� �t t
t | j � dz � � | _ y)a
Calculate statistics for the given image. If a mask is included,
only the regions covered by that mask are included in the
statistics. You can also pass in a previously calculated histogram.
:param image: A PIL image, or a precalculated histogram.
.. note::
For a PIL image, calculations rely on the
:py:meth:`~PIL.Image.Image.histogram` method. The pixel counts are
grouped into 256 bins, even if the image has more than 8 bits per
channel. So ``I`` and ``F`` mode images have a maximum ``mean``,
``median`` and ``rms`` of 255, and cannot have an ``extrema`` maximum
of more than 255.
:param mask: An optional mask.
z$first argument must be image or list� N) �
isinstancer � histogram�h�list� TypeError�range�len�bands)�self�
image_or_list�mask�msgs �8/usr/local/lib/python3.12/site-packages/PIL/ImageStat.py�__init__z
Stat.__init__ sb � �* �m�U�[�[�1�"�,�,�T�2�D�F�
�
�t�
,�"�D�F�8�C��C�.� ��%��D�F�F��s� 2�3�4��
� c � � dd�}t dt | j � d� D �cg c] } || j |d � �� c}S c c}w )au
Min/max values for each band in the image.
.. note::
This relies on the :py:meth:`~PIL.Image.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.Image.getextrema` to
return per-band extrema for the image. This is more correct and
efficient because, for non-8-bit modes, the histogram method uses
:py:meth:`~PIL.Image.Image.getextrema` to determine the bins used.
c � � d\ }}t d� D ] }| | s� |} n t ddd� D ] }| | s� |} ||fS ||fS )N)� r r
r ���)r )r �res_min�res_max�is r �minmaxzStat.extrema.<locals>.minmaxM se � �%��G�W��3�Z���Q�<��G�� � �3��B�'���Q�<��G���G�#�#� (� �G�#�#r r r
N)r � list[int]�returnztuple[int, int])r r r
)r r! r s r �extremazStat.extrema>