Website : rimsha.abasa.com
backdoor
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
lib
/
python3
/
dist-packages
/
PIL
/
__pycache__
/
Filename :
ImageMorph.cpython-310.pyc
back
Copy
o Z#�a] � @ sL d dl Z ddlmZmZ dZg d�Zg d�ZG dd� d�ZG d d � d �ZdS )� N� )�Image� _imagingmorphi ) � � r � � r � � � ) r r r r r r r r r c @ �J e Zd ZdZddd�Zdd� Zdd� Zd d � Zdd� Zd d� Z dd� Z dS )� LutBuilderaT A 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() Nc C st |d ur|| _ ng | _ d | _|d ur8ddgdgddgdgddgg d�d�}||vr1td | d ��|| | _ d S d S )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)�corner� dilation4� dilation8�erosion4�erosion8�edgezUnknown pattern �!)�patterns�lut� Exception)�selfr �op_name�known_patterns� r �0/usr/lib/python3/dist-packages/PIL/ImageMorph.py�__init__@ s ��zLutBuilder.__init__c C s | j |7 _ d S �N�r )r r r r r �add_patternsX s zLutBuilder.add_patternsc s. ddg�d� t � �fdd�tt�D ��| _d S )Nr r � c 3 s � | ]}�|� @ d k V qdS )r Nr )�.0�i��m�symbolsr r � <genexpr>^ s � z/LutBuilder.build_default_lut.<locals>.<genexpr>)� bytearray�range�LUT_SIZEr �r r r% r �build_default_lut[ s "zLutBuilder.build_default_lutc C s | j S r �r r, r r r �get_lut` s zLutBuilder.get_lutc s( t |�dksJ �d�� fdd�|D ��S )z�string_permute takes a pattern and a permutation and returns the string permuted according to the permutation list. � � c 3 s � | ]}� | V qd S r r )r# �p��patternr r r( h s � z-LutBuilder._string_permute.<locals>.<genexpr>)�len�join)r r4 �permutationr r3 r �_string_permutec s zLutBuilder._string_permutec C s� ||fg}d|v r%|d d }t d�D ]}|�| �|d d t�|f� qd|v rCt|�}|d|� D ]\}}|�| �|t�|f� q3d|v rqt|�}|d|� D ]\}}|�dd ��d d��d d �}dt|� }|�||f� qQ|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���r r r �M�N�0�Z�1)r* �appendr8 �ROTATION_MATRIXr5 � MIRROR_MATRIX�replace�int) r � basic_pattern�options�basic_resultr �resr$ �nr4 r r r �_pattern_permutej s$ �zLutBuilder._pattern_permutec C s8 | � � g }| jD ]:}t�d|�dd��}|std| d ��|�d�}|�d�}t|�d��}|�d d��dd�}|| �|||�7 }q t |�D ]\}}|d �dd��dd �}t� |�}||d f||<