
 X                 @   s  d  d l  Z  Gd d   d e  Z Gd d   d e  Z Gd d   d e  Z Gd d	   d	 e  Z Gd
 d   d e  Z Gd d   d e  Z Gd d   d e  Z Gd d   d e  Z	 Gd d   d e  Z
 Gd d   d e  Z Gd d   d e  Z Gd d   d e  Z Gd d   d e  Z Gd d   d e  Z Gd d   d e  Z Gd  d!   d! e  Z Gd" d#   d# e  Z Gd$ d%   d% e  Z Gd& d'   d' e  Z Gd( d)   d) e  Z d S)*    Nc               @   s   e  Z d  Z d S)FilterN)__name__
__module____qualname__ r   r   L/home/ubuntu/projects/ifolica/lib/python3.4/site-packages/PIL/ImageFilter.pyr      s   r   c               @   s4   e  Z d  Z d Z d d d d  Z d d   Z d S)Kernela  
    Create a convolution kernel.  The current version only
    supports 3x3 and 5x5 integer and floating point kernels.

    In the current version, kernels can only be applied to
    "L" and "RGB" images.

    :param size: Kernel size, given as (width, height). In the current
                    version, this must be (3,3) or (5,5).
    :param kernel: A sequence containing kernel weights.
    :param scale: Scale factor. If given, the result for each pixel is
                    divided by this value.  the default is the sum of the
                    kernel weights.
    :param offset: Offset. If given, this value is added to the result,
                    after it has been divided by the scale factor.
    Nr   c             C   sm   | d  k r' t  j d d   |  } n  | d | d t |  k rT t d   n  | | | | f |  _ d  S)Nc             S   s   |  | S)Nr   )abr   r   r   <lambda>.   s    z!Kernel.__init__.<locals>.<lambda>r      z!not enough coefficients in kernel)	functoolsreducelen
ValueError
filterargs)selfsizeZkernelZscaleoffsetr   r   r   __init__+   s
    zKernel.__init__c             C   s.   | j  d k r t d   n  | j |  j   S)NPzcannot filter palette images)moder   filterr   )r   imager   r   r   r   3   s    zKernel.filter)r   r   r   __doc__r   r   r   r   r   r   r      s   r   c               @   s   e  Z d  Z d d   Z d S)BuiltinFilterc             C   s   d  S)Nr   )r   r   r   r   r   :   s    zBuiltinFilter.__init__N)r   r   r   r   r   r   r   r   r   9   s   r   c               @   s4   e  Z d  Z d Z d Z d d   Z d d   Z d S)
RankFilterao  
    Create a rank filter.  The rank filter sorts all pixels in
    a window of the given size, and returns the **rank**'th value.

    :param size: The kernel size, in pixels.
    :param rank: What pixel value to pick.  Use 0 for a min filter,
                 ``size * size / 2`` for a median filter, ``size * size - 1``
                 for a max filter, etc.
    ZRankc             C   s   | |  _  | |  _ d  S)N)r   rank)r   r   r   r   r   r   r   J   s    	zRankFilter.__init__c             C   sT   | j  d k r t d   n  | j |  j d |  j d  } | j |  j |  j  S)Nr   zcannot filter palette images   )r   r   expandr   Z
rankfilterr   )r   r   r   r   r   r   N   s     zRankFilter.filterN)r   r   r   r   namer   r   r   r   r   r   r   >   s   	r   c               @   s+   e  Z d  Z d Z d Z d d d  Z d S)MedianFilterz
    Create a median filter. Picks the median pixel value in a window with the
    given size.

    :param size: The kernel size, in pixels.
    ZMedian   c             C   s   | |  _  | | d |  _ d  S)Nr   )r   r   )r   r   r   r   r   r   ^   s    	zMedianFilter.__init__N)r   r   r   r   r    r   r   r   r   r   r!   U   s   r!   c               @   s+   e  Z d  Z d Z d Z d d d  Z d S)	MinFilterz
    Create a min filter.  Picks the lowest pixel value in a window with the
    given size.

    :param size: The kernel size, in pixels.
    ZMinr"   c             C   s   | |  _  d |  _ d  S)Nr   )r   r   )r   r   r   r   r   r   l   s    	zMinFilter.__init__N)r   r   r   r   r    r   r   r   r   r   r#   c   s   r#   c               @   s+   e  Z d  Z d Z d Z d d d  Z d S)	MaxFilterz
    Create a max filter.  Picks the largest pixel value in a window with the
    given size.

    :param size: The kernel size, in pixels.
    ZMaxr"   c             C   s   | |  _  | | d |  _ d  S)Nr   )r   r   )r   r   r   r   r   r   z   s    	zMaxFilter.__init__N)r   r   r   r   r    r   r   r   r   r   r$   q   s   r$   c               @   s7   e  Z d  Z d Z d Z d d d  Z d d   Z d S)	
ModeFiltera"  

    Create a mode filter. Picks the most frequent pixel value in a box with the
    given size.  Pixel values that occur only once or twice are ignored; if no
    pixel value occurs more than twice, the original pixel value is preserved.

    :param size: The kernel size, in pixels.
    ZModer"   c             C   s   | |  _  d  S)N)r   )r   r   r   r   r   r      s    zModeFilter.__init__c             C   s   | j  |  j  S)N)Z
modefilterr   )r   r   r   r   r   r      s    zModeFilter.filterN)r   r   r   r   r    r   r   r   r   r   r   r%      s   r%   c               @   s7   e  Z d  Z d Z d  Z d d d  Z d d   Z d S)GaussianBlurz;Gaussian blur filter.

    :param radius: Blur radius.
    r   c             C   s   | |  _  d  S)N)radius)r   r'   r   r   r   r      s    zGaussianBlur.__init__c             C   s   | j  |  j  S)N)Zgaussian_blurr'   )r   r   r   r   r   r      s    zGaussianBlur.filterN)r   r   r   r   r    r   r   r   r   r   r   r&      s   r&   c               @   s=   e  Z d  Z d Z d  Z d d d d d  Z d d   Z d	 S)
UnsharpMaska  Unsharp mask filter.

    See Wikipedia's entry on `digital unsharp masking`_ for an explanation of
    the parameters.

    :param radius: Blur Radius
    :param percent: Unsharp strength, in percent
    :param threshold: Threshold controls the minimum brightness change that
      will be sharpened

    .. _digital unsharp masking: https://en.wikipedia.org/wiki/Unsharp_masking#Digital_unsharp_masking

    r      r"   c             C   s   | |  _  | |  _ | |  _ d  S)N)r'   percent	threshold)r   r'   r*   r+   r   r   r   r      s    		zUnsharpMask.__init__c             C   s   | j  |  j |  j |  j  S)N)Zunsharp_maskr'   r*   r+   )r   r   r   r   r   r      s    zUnsharpMask.filterN)r   r   r   r   r    r   r   r   r   r   r   r(      s   r(   c               @   s   e  Z d  Z d Z d	 Z d S)
BLURZBlur      r   r   Nr-   r-   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r/   r.   r   r0   )r   r   r   r    r   r   r   r   r   r,      s        r,   c               @   s   e  Z d  Z d Z d Z d S)CONTOURZContourr"   r         Nr"   r"   r5   r5   r5   r5   r5   r5   r5   	r5   r5   r5   r5   r3   r5   r5   r5   r5   )r4   r   r2   r6   )r   r   r   r    r   r   r   r   r   r1      s
      r1   c               @   s   e  Z d  Z d Z d Z d S)DETAILZDetailr"      r   r   
   Nr"   r"   r5   r5   r5   r5   	r   r5   r   r5   r9   r5   r   r5   r   )r:   r8   r   r;   )r   r   r   r    r   r   r   r   r   r7      s
      r7   c               @   s   e  Z d  Z d Z d Z d S)EDGE_ENHANCEzEdge-enhancer"   r   r   r   r9   Nr"   r"   r5   r5   r5   r5   r5   r5   r5   r5   	r5   r5   r5   r5   r9   r5   r5   r5   r5   )r=   r   r   r>   )r   r   r   r    r   r   r   r   r   r<      s
      r<   c               @   s   e  Z d  Z d Z d Z d S)EDGE_ENHANCE_MOREzEdge-enhance Morer"   r   r   	   Nr"   r"   r5   r5   r5   r5   r5   r5   r5   r5   	r5   r5   r5   r5   r@   r5   r5   r5   r5   )rA   r   r   rB   )r   r   r   r    r   r   r   r   r   r?      s
      r?   c               @   s   e  Z d  Z d Z d
 Z d S)EMBOSSZEmbossr"   r      r   Nr"   r"   r5   	r5   r   r   r   r   r   r   r   r   )rE   r   rD   rF   )r   r   r   r    r   r   r   r   r   rC      s
      rC   c               @   s   e  Z d  Z d Z d Z d S)
FIND_EDGESz
Find Edgesr"   r   r   r3   Nr"   r"   r5   r5   r5   r5   r5   r5   r5   r5   	r5   r5   r5   r5   r3   r5   r5   r5   r5   )rH   r   r   rI   )r   r   r   r    r   r   r   r   r   rG      s
      rG   c               @   s   e  Z d  Z d Z d
 Z d S)SMOOTHZSmoothr"      r   r   r-   Nr"   r"   	r   r   r   r   r-   r   r   r   r   )rL   rK   r   rM   )r   r   r   r    r   r   r   r   r   rJ      s
      rJ   c               @   s   e  Z d  Z d Z d
 Z d S)SMOOTH_MOREzSmooth Morer-   d   r   r   ,   Nr-   r-   r   r   r   r   r   r   r-   r-   r-   r   r   r-   rP   r-   r   r   r-   r-   r-   r   r   r   r   r   r   )rQ   rO   r   rR   )r   r   r   r    r   r   r   r   r   rN     s        rN   c               @   s   e  Z d  Z d Z d Z d S)SHARPENZSharpenr"   r.   r   r       Nr"   r"   rV   rV   rV   rV   rV   rV   rV   	rV   rV   rV   rV   rT   rV   rV   rV   rV   )rU   r.   r   rW   )r   r   r   r    r   r   r   r   r   rS     s
      rS   )r   objectr   r   r   r   r!   r#   r$   r%   r&   r(   r,   r1   r7   r<   r?   rC   rG   rJ   rN   rS   r   r   r   r   <module>   s(    							