File: //home/arjun/projects/env/lib/python3.10/site-packages/PIL/__pycache__/ImageMorph.cpython-310.pyc
o
we) � @ 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 sx |d ur|| _ ng | _ d | _|d ur:ddgdgddgdgddgg d�d�}||vr3d | d
}t|��|| | _ 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�msg� r �G/home/arjun/projects/env/lib/python3.10/site-packages/PIL/ImageMorph.py�__init__@ s"