Sindbad~EG File Manager
�
&ٜgs! � �d � d dl mZ d dlZddlmZmZ dZg d�Zg d�Z G d� d � Z G d
� d� Z
y)� )�annotationsN� )�Image�
_imagingmorphi ) � � r � � r � � � ) r
r r r r
r r r r c �f � e Zd ZdZ d
dd�Zdd�Zd
d�Zdd�Zdd�Z dd�Z dd �Z
y)�
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 � � |�|| _ ng | _ d | _ |�3ddgdgddgdgddgg d�d�}||vrd |� d
�}t |� �|| | _ y y )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�msgs �9/usr/local/lib/python3.12/site-packages/PIL/ImageMorph.py�__init__zLutBuilder.__init__A s� � � ��$�D�M��D�M�%)�����/�1E�F�2�3�2�4H�I�1�2�1�3G�H��
�N� �n�,�(�� ��3����n�$�*�7�3�D�M�# � c �. � | xj |z
c_ y �N�r )r r s r �add_patternszLutBuilder.add_patterns\ s � ��
�
��!�
r"