Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
ImageStat.cpython-313.pyc62 linesDownload Raw Back to __pycache__
1�

2v�j��H�SSKJr SSKrSSKJr SSKJr "SS5r\rg)�)�annotationsN)�cached_property�)�Imagec���\rSrSrSSSjjr\SSj5r\SSj5r\SSj5r\SSj5r	\SSj5r3\SS	j5r\SS4j5r\SSj5r
\SSj5rS
rg)�Stat�Nc� �[U[R5(aURU5UlO)[U[5(aXlO
Sn[U5e[	[
[UR5S-55Ulg)a�5Calculate statistics for the given image. If a mask is included,6only the regions covered by that mask are included in the7statistics. You can also pass in a previously calculated histogram.8 9:param image: A PIL image, or a precalculated histogram.10 11    .. note::12 13        For a PIL image, calculations rely on the14        :py:meth:`~PIL.Image.Image.histogram` method. The pixel counts are15        grouped into 256 bins, even if the image has more than 8 bits per16        channel. So ``I`` and ``F`` mode images have a maximum ``mean``,17        ``median`` and ``rms`` of 255, and cannot have an ``extrema`` maximum18        of more than 255.19 20:param mask: An optional mask.21z$first argument must be image or list�N)	�22isinstancer�	histogram�h�list�	TypeError�range�len�bands)�self�
image_or_list�mask�msgs    �SD:\code\apps\devtools\python\user_packages\Python313\site-packages\PIL/ImageStat.py�__init__�
Stat.__init__ sf��*�m�U�[�[�1�1�"�,�,�T�2�D�F�
�
�t�
,�
,�"�F�8�C��C�.� ��%��D�F�F��s� 2�3�4��23�c��SSjn[S[UR5S5Vs/sHo!"URUS5PM sn$s snf)a%24Min/max values for each band in the image.25 26.. note::27    This relies on the :py:meth:`~PIL.Image.Image.histogram` method, and28    simply returns the low and high bins used. This is correct for29    images with 8 bits per channel, but fails for other modes such as30    ``I`` or ``F``. Instead, use :py:meth:`~PIL.Image.Image.getextrema` to31    return per-band extrema for the image. This is more correct and32    efficient because, for non-8-bit modes, the histogram method uses33    :py:meth:`~PIL.Image.Image.getextrema` to determine the bins used.34c��Sup[S5HnX(dMUn O [SSS5HnX(dMUn X4$ X4$)N)��rrr�����)r)r
�res_min�res_max�is    r�minmax�Stat.extrema.<locals>.minmaxMs_��%��G��3�Z���<�<��G�� ��3��B�'���<�<��G���#�#�	(��#�#rrrN)r
�	list[int]�returnztuple[int, int])rrr)rr#r"s   r�extrema�Stat.extrema>sC��35	$�-2�!�S����[�#�,F�G�,F�q��t�v�v�a�b�z�"�,F�G�G��Gs�A	c	��[S[UR5S5Vs/sHn[URXS-5PM sn$s snf)z2Total number of pixels for each band in the image.rr)rrr�sum�rr"s  r�count�36Stat.count[sA��38��3�t�v�v�;��2L�M�2L�Q��D�F�F�1�3�w�'�(�2L�M�M��Ms�$A37c���/n[S[UR5S5H>nSn[S5HnX4URX$---
nM URU5 M@ U$)z-Sum of all pixels for each band in the image.rr�)rrr�append)r�vr"�	layer_sum�js     rr*�Stat.sum`sa��
���q�#�d�f�f�+�s�+�A��I��3�Z���������.�.�	� �
�H�H�Y��	,�38�rc	���/n[S[UR5S5HJnSn[S5H%nX4S-[URX$-5--
nM' UR	U5 ML U$)z5Squared sum of all pixels for each band in the image.rrr/�)rrr�floatr0)rr1r"�sum2r3s     rr8�	Stat.sum2lsi��
���q�#�d�f�f�+�s�+�A��D��3�Z���A���t�v�v�a�e�}�!5�5�5�� �
�H�H�T�N�	,�39�rc��URVs/sH7oRU(aURUURU-OSPM9 sn$s snf)zAAverage (arithmetic mean) pixel level for each band in the image.r)rr,r*r+s  r�mean�	Stat.meanxsD��NR�Z�Z�X�Z��z�z�!�}������d�j�j��m�+�!�C�Z�X�X��Xs�>Ac���/nURHYnSnURUS-nUS-n[S5HnX0RXV--nX4:�dM O UR	W5 M[ U$)z.Median pixel level for each band in the image.rr6r)rr,rrr0)rr1r"�s�half�br3s       r�median�Stat.median}ss��
�����A��A��:�:�a�=�A�%�D��C��A��3�Z�����q�u�
�%���8�� �
�H�H�Q�K���rc���URVs/sHLnURU(a3[R"URUURU-5OSPMN sn$s snf)z2RMS (root-mean-square) for each band in the image.r)rr,�math�sqrtr8r+s  r�rms�Stat.rms�sZ��40�Z�Z�41���8<�z�z�!�}�D�I�I�d�i�i��l�T�Z�Z��]�2�3�!�K��42�	43��44s�AA%c���URVs/sH[nURU(aBURUURUS-URU--45URU-OSPM] sn$s snf)z$Variance for each band in the image.g@r)rr,r8r*r+s  r�var�Stat.var�s{���Z�Z�
46� ���:�:�a�=����1�����!���!3�t�z�z�!�}� D�D��47�48�ST�
�U��� �
49�	50��51s�A"A4c��URVs/sH&n[R"URU5PM( sn$s snf)z.Standard deviation for each band in the image.)rrDrErIr+s  r�stddev�Stat.stddev�s1��15�52�53�;�54�1��	�	�$�(�(�1�+�&�55�;�;��;s�-?)rr)N)rzImage.Image | list[int]rzImage.Image | Noner&�None)r&zlist[tuple[int, int]])r&r%)r&zlist[float])�__name__�56__module__�__qualname__�__firstlineno__rrr'r,r*r8r;rArFrIrL�__static_attributes__�rrrrs���QU�5�4�5�<N�5�	
�5�<�H��H�8�N��N��	��	��	��	��Y��Y��
��
��57��58��	59��	60��<��<rr)	�61__future__rrD�	functoolsr�rr�GlobalrTrr�<module>rYs'��.#��%��E<�E<�P62�r
codekingpro/portable-devtools · Team Ai