Ñò
…n+Oc           @   sA   d  d k  Z  d  d k Z d  d k Z d d d „  ƒ  YZ e Z d S(   iÿÿÿÿNt   Statc           B   st   e  Z d  Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d „  Z RS(   s   Get image or feature statisticsc         C   s˜   y0 | o | i  | ƒ |  _ n | i  ƒ  |  _ Wn t j
 o | |  _ n Xt |  i ƒ t g  ƒ j o t d ‚ n t t |  i ƒ d ƒ |  _ d  S(   Ns$   first argument must be image or listi   (   t	   histogramt   ht   AttributeErrort   typet	   TypeErrort   ranget   lent   bands(   t   selft   image_or_listt   mask(    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageStat.pyt   __init__/   s    c         C   sH   | d  d j o t  | ‚ n t |  d | ƒ ƒ  } t |  | | ƒ | S(   s   Calculate missing attributei   t   _get(   R   t   getattrt   setattr(   R	   t   idt   v(    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageStat.pyt   __getattr__;   s
    c         C   sS   d „  } g  } x= t  d t |  i ƒ d ƒ D]  } | i | |  i | ƒ ƒ q+ W| S(   s-   Get min/max values for each band in the imagec         S   sZ   d } d } xA t  d ƒ D]3 } |  | o" t | | ƒ } t | | ƒ } q q W| | f S(   Niÿ   i    i   (   R   t   mint   max(   R   t   nt   xt   i(    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageStat.pyt   minmaxG   s     i    i   (   R   R   R   t   append(   R	   R   R   R   (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageStat.pyt   _getextremaD   s    		 c         C   sW   g  } xJ t  d t |  i ƒ d ƒ D]- } | i t t i |  i | | d !ƒ ƒ q" W| S(   s(   Get total number of pixels in each layeri    i   (   R   R   R   R   t   reducet   operatort   add(   R	   R   R   (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageStat.pyt	   _getcountU   s
     +c         C   ss   g  } xf t  d t |  i ƒ d ƒ D]I } d } x- t  d ƒ D] } | | |  i | | } q; W| i | ƒ q" W| S(   s#   Get sum of all pixels in each layeri    i   g        (   R   R   R   R   (   R	   R   R   t   sumt   j(    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageStat.pyt   _getsum]   s      c         C   s}   g  } xp t  d t |  i ƒ d ƒ D]S } d } x7 t  d ƒ D]) } | | d t |  i | | ƒ } q; W| i | ƒ q" W| S(   s+   Get squared sum of all pixels in each layeri    i   g        i   (   R   R   R   t   floatR   (   R	   R   R   t   sum2R    (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageStat.pyt   _getsum2h   s      'c         C   s=   g  } x0 |  i  D]% } | i |  i | |  i | ƒ q W| S(   s&   Get average pixel level for each layer(   R   R   R   t   count(   R	   R   R   (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageStat.pyt   _getmeans   s
    
 #c         C   sŠ   g  } x} |  i  D]r } d } |  i | d } | d } x; t d ƒ D]- } | |  i | | } | | j o PqD qD W| i | ƒ q W| S(   s%   Get median pixel level for each layeri    i   i   (   R   R%   R   R   R   (   R	   R   R   t   st   lt   bR    (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageStat.pyt
   _getmedian{   s    
 
 	c         C   sF   g  } x9 |  i  D]. } | i t i |  i | |  i | ƒ ƒ q W| S(   s   Get RMS for each layer(   R   R   t   matht   sqrtR#   R%   (   R	   R   R   (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageStat.pyt   _getrmsŠ   s
    
 ,c         C   sV   g  } xI |  i  D]> } |  i | } | i |  i | |  i | d | | ƒ q W| S(   s   Get variance for each layerg       @(   R   R%   R   R#   R   (   R	   R   R   R   (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageStat.pyt   _getvar“   s    
 /c         C   s;   g  } x. |  i  D]# } | i t i |  i | ƒ ƒ q W| S(   s%   Get standard deviation for each layer(   R   R   R+   R,   t   var(   R	   R   R   (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageStat.pyt
   _getstddevœ   s
    
 !N(   t   __name__t
   __module__t   __doc__t   NoneR   R   R   R   R!   R$   R&   R*   R-   R.   R0   (    (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageStat.pyR    %   s   													(    (   t   ImageR   R+   R    t   Global(    (    (    s7   /usr/local/lib/python2.6/dist-packages/PIL/ImageStat.pyt   <module>   s   