OwlCyberSecurity - MANAGER
Edit File: ImageMorph.cpython-38.pyc
U g� ^� � @ sh d dl Z ddlmZmZ dZddd dddd d dg Zddd d ddd ddg ZG dd � d �ZG dd� d�ZdS )� N� )�Image� _imagingmorphi � � � � � � � c @ sJ e Zd ZdZddd�Zdd� Zdd� Zd d � Zdd� Zd d� Z dd� Z dS )� LutBuildera~ 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 sr |d k r|| _ ng | _ d | _|d k rnddgdgddgdgddgdddgd �}||krdtd | d ��|| | _ d S )Nz1:(... ... ...)->0z4:(00. 01. ...)->1z4:(... .0. .1.)->1z4:(... .0. ..1)->1z4:(... .1. .0.)->0z4:(... .1. ..0)->0z4:(.0. .1. ...)->1z4:(01. .1. ...)->1)ZcornerZ dilation4Z dilation8Zerosion4Zerosion8ZedgezUnknown pattern �!)�patterns�lut� Exception)�selfr �op_nameZknown_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��mZsymbolsr 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"