+
     i  c                  sJ    ^ RI Ht ^ RIt^ RIHt ^RIHt  ! R R4      t]tR# )i    )annotationsN)cached_property)Imagec                  s    ] tR t^tRR R llt]R R l4       t]R R l4       t]R R	 l4       t]R
 R l4       t	]R R l4       t
]R R l4       t]R R l4       t]R R l4       t]R R l4       tRtR# )StatNc               s$    V ^8  d   QhRRRRRR/# )   image_or_listzImage.Image | list[int]maskzImage.Image | NonereturnZNone Zformat   "4/usr/lib64/python3.14/site-packages/PIL/ImageStat.py__annotate__Stat.__annotate__    s$     5 545<N5	5    c                s.   \        V\        P                  4      '       d   VP                  V4      V n        M*\        V\        4      '       d   Wn        MRp\        V4      h\	        \        \        V P                  4      R,          4      4      V n        R# )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)	Z
isinstancer   	histogramhZlistZ	TypeErrorrangelenbands)selfr   r   Zmsgs   &&& r   __init__ZStat.__init__    sf    * mU[[11",,T2DFt,,"F8CC. %DFFs 234
r   c                   V ^8  d   QhRR/# )r   r   zlist[tuple[int, int]]r   r	   r
   r   r   r   ?   s     H H. Hr   c                s    R R lp\        ^ \        V P                  4      R4       Uu. uF  q!! V P                  VR 4      NK  	  up# u upi )a%  
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               s     V ^8  d   QhRRRR/# )r   r   	list[int]r   ztuple[int, int]r   r	   r
   r   r   Z"Stat.extrema.<locals>.__annotate__M   s     
	$ 
	$i 
	$O 
	$r   c                s    ^^ r!\        R4       F  pW,          '       g   K  Tp M	  \        ^RR4       F  pW,          '       g   K  Tp W3# 	  W3# )i   r   i)r   )r   Zres_minZres_maxis   &   r   minmaxZStat.extrema.<locals>.minmaxM   s^    "AW3Z<<G   3B'<<G##	 ( ##r   r   N)r   r   r   )r   r   r   s   &  r   extremaZStat.extrema>   sC    
	$ -2!S[#,FG,Fqtvvabz",FGGGs   A	c               r   r   r   r   r   r	   r
   r   r   r   \   s     N Ny Nr   c           	     s    \        ^ \        V P                  4      R4       Uu. uF!  p\        V P                  WR,            4      NK#  	  up# u upi )z2Total number of pixels for each band in the image.r   )r   r   r   sumr   r      & r   countZ
Stat.count[   sA     383tvv;2LM2LQDFF13w'(2LMMMs   'Ac               r   r   r   zlist[float]r   r	   r
   r   r   r   a   s     	 	[ 	r   c                s    . p\        ^ \        V P                  4      R4       FN  pRp\        R4       F)  pW4V P                  W$,           ,          ,          ,          pK+  	  VP                  V4       KP  	  V# )z-Sum of all pixels for each band in the image.r           )r   r   r   append)r   vr   Z	layer_sumj   &    r   r   ZStat.sum`   sa     q#dff+s+AI3Z..	  HHY	 ,
 r   c               r   r!   r   r	   r
   r   r   r   m   s     	 	k 	r   c           	     s   . p\        ^ \        V P                  4      R4       F^  pRp\        R4       F9  pW4^,          \        V P                  W$,           ,          4      ,          ,          pK;  	  VP	                  V4       K`  	  V# )z5Squared sum of all pixels for each band in the image.r   r"   )r   r   r   Zfloatr#   )r   r$   r   sum2r%   r&   r   r'   Z	Stat.sum2l   si     q#dff+s+AD3ZAtvvae}!555  HHTN	 ,
 r   c               r   r!   r   r	   r
   r   r   r   y   s     A Ak Ar   c                s    V P                    Uu. uF-  qP                  V,          V P                  V,          ,          NK/  	  up# u upi )zAAverage (arithmetic mean) pixel level for each band in the image.)r   r   r    r   r   r   meanZ	Stat.meanx   s6     6:ZZ@Zdjjm++Z@@@s   3Ac               r   r   r   r	   r
   r   r   r   ~   s      	 r   c                s   . pV P                    Fr  p^ pV P                  V,          ^,          pVR,          p\        R4       F*  pW0P                  WV,           ,          ,           pW48  g   K*   M	  VP	                  X4       Kt  	  V# )z.Median pixel level for each band in the image.r   )r   r    r   r   r#   )r   r$   r   ZsZhalfZbr%   s   &      r   medianZStat.median}   ss     AA::a=A%DCA3Zqu%8   HHQK  r   c               r   r!   r   r	   r
   r   r   r      s     M M[ Mr   c                s    V P                    Uu. uFB  p\        P                  ! V P                  V,          V P                  V,          ,          4      NKD  	  up# u upi )z2RMS (root-mean-square) for each band in the image.)r   mathsqrtr'   r    r   r   r   rmsZStat.rms   s@     BFLA		$))A,A67LLLs   AAc               r   r!   r   r	   r
   r   r   r      s     
 
[ 
r   c                s   V P                    Uu. uFe  pV P                  V,          V P                  V,          R,          V P                  V,          ,          ,
          V P                  V,          ,          NKg  	  up# u upi )z$Variance for each band in the image.g       @)r   r'   r   r    r   r   r   varZStat.var   sd    
 ZZ
 YYq\TXXa[C/4::a=@@DJJqMQQ
 	
 
s   A+A=c               r   r!   r   r	   r
   r   r   r      s     < < <r   c                s    V P                    Uu. uF*  p\        P                  ! V P                  V,          4      NK,  	  up# u upi )z.Standard deviation for each band in the image.)r   r*   r+   r-   r   r   r   stddevZStat.stddev   s1     15

;
1		$((1+&
;;;s   0A)r   r   )N)Z__name__Z
__module__Z__qualname__Z__firstlineno__r   r   r   r    r   r'   r(   r)   r,   r-   r.   Z__static_attributes__r   r   r   r   r      s    5< H H8 N N 	 	 	 	 A A   M M 
 
 < <r   r   )	Z
__future__r    r*   Z	functoolsr   Z r   r   ZGlobalr   r   r   <module>r/      s'   . #  % ~< ~<B 
r   