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ãóHddlmZddlZddlmZddlmZGdd«ZeZy)é)Ú annotationsN)Úcached_propertyé)ÚImagecóÄeZdZ d d
dZedd«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Ú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§[¡[Ô "×,¨TÓ2ˆD
˜
¤tÔ
"ˆD8ˆ˜C“.Ð Üœ%¤ D§F¡F£ ¨sÑ 2Ó
ócó–dd}tdt|j«d«Dcgc]}||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˜3“Zò
ؘQ“<Øð
ô˜3  
ؘQ“<ØØ˜ 
ð˜ #rrr
N)r ú list[int]Úreturnztuple[int, int])rrr
)rr!r s rÚextremaz Stat.extrema>s=ó
-2°!´S¸¿¹³[À#Ó,FÖG qt—vv˜a˜bGùÒGs§Ac óštdt|j«d«Dcgc]}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—FF˜1˜q 3™wÐ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 ð  ð
ˆ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ò