ó <×ï[c@sDddlZddlZddlZdefd„ƒYZeZdS(iÿÿÿÿNtStatcBsneZd d„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d„Z d „Z d „Z RS( cCs’y.|r|j|ƒ|_n|jƒ|_Wntk rJ||_nXt|jtƒsltdƒ‚nttt|jƒdƒƒ|_dS(Ns$first argument must be image or listi( t histogramthtAttributeErrort isinstancetlistt TypeErrortrangetlentbands(tselft image_or_listtmask((s-/tmp/pip-build-SKekGm/pillow/PIL/ImageStat.pyt__init__s  cCsI|d dkrt|ƒ‚nt|d|ƒƒ}t|||ƒ|S(sCalculate missing attributeit_get(Rtgetattrtsetattr(R tidtv((s-/tmp/pip-build-SKekGm/pillow/PIL/ImageStat.pyt __getattr__+s cCsSd„}g}x=tdt|jƒdƒD] }|j||j|ƒƒq+W|S(s-Get min/max values for each band in the imagecSsXd}d}x?tdƒD]1}||rt||ƒ}t||ƒ}qqW||fS(Niÿii(Rtmintmax(Rtntxti((s-/tmp/pip-build-SKekGm/pillow/PIL/ImageStat.pytminmax7s ii(RRRtappend(R RRR((s-/tmp/pip-build-SKekGm/pillow/PIL/ImageStat.pyt _getextrema4s  "cCsZg}xMtdt|jƒdƒD]0}|jtjtj|j||d!ƒƒq"W|S(s(Get total number of pixels in each layerii(RRRRt functoolstreducetoperatortadd(R RR((s-/tmp/pip-build-SKekGm/pillow/PIL/ImageStat.pyt _getcountEs".cCssg}xftdt|jƒdƒD]I}d}x-tdƒD]}|||j||7}q;W|j|ƒq"W|S(s#Get sum of all pixels in each layeriig(RRRR(R RRtlayerSumtj((s-/tmp/pip-build-SKekGm/pillow/PIL/ImageStat.pyt_getsumMs"cCs}g}xptdt|jƒdƒD]S}d}x7tdƒD])}||dt|j||ƒ7}q;W|j|ƒq"W|S(s+Get squared sum of all pixels in each layeriigi(RRRtfloatR(R RRtsum2R"((s-/tmp/pip-build-SKekGm/pillow/PIL/ImageStat.pyt_getsum2Xs"'cCs=g}x0|jD]%}|j|j||j|ƒqW|S(s&Get average pixel level for each layer(R Rtsumtcount(R RR((s-/tmp/pip-build-SKekGm/pillow/PIL/ImageStat.pyt_getmeancs#cCsˆg}x{|jD]p}d}|j|d}|d}x9tdƒD]+}||j||}||krDPqDqDW|j|ƒqW|S(s%Get median pixel level for each layeriii(R R(RRR(R RRtsthalftbR"((s-/tmp/pip-build-SKekGm/pillow/PIL/ImageStat.pyt _getmedianks  cCsFg}x9|jD].}|jtj|j||j|ƒƒqW|S(sGet RMS for each layer(R RtmathtsqrtR%R((R RR((s-/tmp/pip-build-SKekGm/pillow/PIL/ImageStat.pyt_getrmszs,cCsVg}xI|jD]>}|j|}|j|j||j|d||ƒqW|S(sGet variance for each layerg@(R R(RR%R'(R RRR((s-/tmp/pip-build-SKekGm/pillow/PIL/ImageStat.pyt_getvar‚s  /cCs;g}x.|jD]#}|jtj|j|ƒƒqW|S(s%Get standard deviation for each layer(R RR.R/tvar(R RR((s-/tmp/pip-build-SKekGm/pillow/PIL/ImageStat.pyt _getstddev‹s!N(t__name__t __module__tNoneR RRR R#R&R)R-R0R1R3(((s-/tmp/pip-build-SKekGm/pillow/PIL/ImageStat.pyRs      (R.RRtobjectRtGlobal(((s-/tmp/pip-build-SKekGm/pillow/PIL/ImageStat.pyts   w