Files
intellecton/venv/lib/python3.12/site-packages/PIL/__pycache__/ImageStat.cpython-312.pyc
T

67 lines
7.4 KiB
Plaintext
Raw Normal View History

Ë
ß¼jwãóH—ddlmZddlZddlmZddlmZGd„d«ZeZy)é)Ú annotationsN)Úcached_propertyé)ÚImagecóÄ—eZdZ d d
d„Zedd„«Zedd„«Zedd„«Zedd„«Zedd„«Z edd„«Z
edd „«Z edd
„«Z edd „«Z
y)ÚStatNcó—t|tj«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 úP/home/antigravity/intellecton/venv/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„}tdt|j«d«D�cgc]}||j|d«‘Œc}Scc}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\}}td«D] }||sŒ |}ntddd«D]}||sŒ |}||fS||fS)N)éÿrr
réÿÿÿÿ)r)r Úres_minÚres_maxÚis rÚminmaxzStat.extrema.<locals>.minmaxMso€Ø%Ñ ˆG�Wܘ3“Zò
�ؘQ“<Ø�GÙð
ô˜3  BÓ'ò
�ؘQ“<Ø�GØØ˜GÐ#Ð #ð 
ð˜GÐ#Ð #rrr
N)r ú list[int]Úreturnztuple[int, int])rrr
)rr!r s rÚextremaz Stat.extrema>s=€ó
$ô-2°!´S¸¿¹³[À#Ó,FÖG q‘�t—v‘v˜a˜b�zÕ"ÒGÐGùÒGs§Ac óš—tdt|j«d«D�cgc]}t|j||dz«‘Œc}Scc}w)z2Total number of pixels for each band in the image.rr
)rrr
Úsum©rr s rÚcountz
Stat.count[s=€ô38¸¼3¸t¿v¹v»;ÈÓ2LÖM¨Q”�D—F‘F˜1˜q 3™wÐ'Õ(ÒMÐMùÒMs£"AcóÊ—g}tdt|j«d«D]=}d}td«D]}|||j||zzz
}Œ|j|«Œ?|S)z-Sum of all pixels for each band in the image.rr
ç)rrr
Úappend)rÚvr Ú layer_sumÚjs rr&zStat.sum`so€ð
ˆÜ�qœ#˜dŸf™f›+ sÓ+ò ˆA؈Iܘ3“Zò
/�ؘQ §¡¨¨A©¡Ñ.Ñ.‘ ð
/à
�H‰H�YÕ ð  ð
ˆrc óâ—g}tdt|j«d«D]I}d}td«D]&}||dzt|j||z«zz
}Œ(|j |«ŒK|S)z5Squared sum of all pixels for each band in the image.rr
r*é)rrr
Úfloatr+)rr,r Úsum2r.s rr2z Stat.sum2lsw€ð
ˆÜ�qœ#˜dŸf™f›+ sÓ+ò ˆA؈Dܘ3“Zò