class_docstr: 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()
class_docstr_tok: ["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","(",")"]
code: def __init__(self, patterns=None, op_name=None):
      if patterns is not None:
          self.patterns = patterns
      else:
          self.patterns = []
      self.lut = None
      if op_name is not None:
          known_patterns = {
              "corner": ["1:(... ... ...)->0", "4:(00. 01. ...)->1"],
              "dilation4": ["4:(... .0. .1.)->1"],
              "dilation8": ["4:(... .0. .1.)->1", "4:(... .0. ..1)->1"],
              "erosion4": ["4:(... .1. .0.)->0"],
              "erosion8": ["4:(... .1. .0.)->0", "4:(... .1. ..0)->0"],
              "edge": [
                  "1:(... ... ...)->0",
                  "4:(.0. .1. ...)->1",
                  "4:(01. .1. ...)->1",
              ],
          }
          if op_name not in known_patterns:
              msg = "Unknown pattern " + op_name + "!"
              raise Exception(msg)
  
          self.patterns = known_patterns[op_name]
  
file_path: catboost/contrib/python/Pillow/py3/PIL/ImageMorph.py
imports: import re
  from .None import Image, _imagingmorph
label_desc: Use image node_id 1 to create a new LutBuilder object  with example: obj = LutBuilder(patterns, op_name)