1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
Ë
³òúhãó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    ú@H:\Change_password\venv_build\Lib\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ò 6Ø˜˜A™¤ t§v¡v¨a°!©e¡}Ó!5Ñ5Ñ5‘ð 6à H‰HTNð        ð
ˆrcóœ—|jDcgc]2}|j|r|j||j|z nd‘Œ4c}Scc}w)zAAverage (arithmetic mean) pixel level for each band in the image.r)rr(r&r's  rÚmeanz    Stat.meanxsB€ðNRÏZÉZÖXȨt¯z©z¸!ª}—‘˜‘ ˜dŸj™j¨™mÒ+À!ÑCÒXÐXùÒXs7A    cóؗg}|jD]X}d}|j|dz}|dz}td«D]}||j||zz}||kDsŒn|j    «ŒZ|S)z.Median pixel level for each band in the image.rr0r
)rr(rr r+)rr,r ÚsÚhalfÚbr.s       rÚmedianz Stat.median}sƒ€ð ˆØ—‘ò    ˆA؈AØ—:‘:˜a‘= AÑ%ˆDؐC‘ˆAܘ3“Zò Ø˜Ÿ™˜q 1™u™ Ñ%Øt“8Ùð ð H‰HQKð    ðˆrcó—|jDcgc]E}|j|r2tj|j||j|z «nd‘ŒGc}Scc}w)z2RMS (root-mean-square) for each band in the image.r)rr(ÚmathÚsqrtr2r's  rÚrmszStat.rmssU€ð
—Z‘Zö
àð8<·z±zÀ!²}ŒDI‰Id—i‘i ‘l T§Z¡Z°¡]Ñ2Ô 3È!Ñ Kò
ð    
ùò
sA
Acóâ—|jDcgc]U}|j|rB|j||j|dz|j|z z
|j|z nd‘ŒWc}Scc}w)z$Variance for each band in the image.g@r)rr(r2r&r's  rÚvarzStat.var•st€ð—Z‘Zö 
ð ð—:‘:˜a’=𗑘1‘ §¡¨!¡°Ñ!3°t·z±zÀ!±}Ñ DÑDÈÏ
É
ÐSTÉ ÒUàñò
ð    
ùò
sAA,có€—|jDcgc]$}tj|j|«‘Œ&c}Scc}w)z.Standard deviation for each band in the image.)rr;r<r?r's  rÚstddevz Stat.stddev¡s-€ð15·
±
Ö;¨1”—    ‘    ˜$Ÿ(™( 1™+Õ&Ò;Ð;ùÒ;s);)N)rzImage.Image | list[int]rzImage.Image | Noner#ÚNone)r#zlist[tuple[int, int]])r#r")r#z list[float])Ú__name__Ú
__module__Ú __qualname__rrr$r(r&r2r4r9r=r?rA©rrrrs܄àQUð5Ø4ð5Ø<Nð5à     ó5ð<òHóðHð8òNóðNðò    óð    ðò    óð    ðòYóðYðò óð ðò
óð
ðò    
óð    
ðò<óñ<rr)    Ú
__future__rr;Ú    functoolsrÚrrÚGlobalrFrrú<module>rKs'ðõ.#ã Ý%å÷E<ñE<ðP
r