class_docstr: Image signature generator.
  
  Based on the method of Goldberg, et al. Available at http://www.cs.cmu.edu/~hcwong/Pdfs/icip02.ps
docstr: Computes array of greyness means.
  
  Corresponds to 'step 3'
  
  Args:
      image (numpy.ndarray): n x m array of floats -- the greyscale image. Typically,
          the output of preprocess_image
      x_coords (numpy.ndarray): array of row numbers
      y_coords (numpy.ndarray): array of column numbers
      P (Optional[int]): size of boxes in pixels (default None)
  
  Returns:
      an N x N array of average greyscale around the gridpoint, where N is the
          number of grid points
  
  Examples:
      >>> img = gis.preprocess_image('https://pixabay.com/static/uploads/photo/2012/11/28/08/56/mona-lisa-67506_960_720.jpg')
      >>> window = gis.crop_image(img)
      >>> grid = gis.compute_grid_points(img, window=window)
      >>> gis.compute_mean_level(img, grid[0], grid[1])
      array([[ 0.62746325,  0.62563642,  0.62348078,  0.50651686,  0.37438874,
               0.0644063 ,  0.55968952,  0.59356148,  0.60473832],
             [ 0.35337797,  0.50272543,  0.27711346,  0.42384226,  0.39006181,
               0.16773968,  0.10471924,  0.33647144,  0.62902124],
             [ 0.20307514,  0.19021892,  0.12435402,  0.44990121,  0.38527996,
               0.08339507,  0.05530059,  0.18469107,  0.21125228],
             [ 0.25727387,  0.1669419 ,  0.08964046,  0.1372754 ,  0.48529236,
               0.39894004,  0.10387907,  0.11282135,  0.30014612],
             [ 0.23447867,  0.15702549,  0.25232943,  0.75172715,  0.79488688,
               0.4943538 ,  0.29645163,  0.10714578,  0.0629376 ],
             [ 0.22167555,  0.04839472,  0.10125833,  0.1550749 ,  0.14346914,
               0.04713144,  0.10095568,  0.15349296,  0.04456733],
             [ 0.09233709,  0.11210942,  0.05361996,  0.07066566,  0.04191625,
               0.03548839,  0.03420656,  0.05025029,  0.03519956],
             [ 0.19226873,  0.20647194,  0.62972106,  0.45514529,  0.05620413,
               0.03383168,  0.03413588,  0.04741828,  0.02987698],
             [ 0.05799523,  0.23310153,  0.43719717,  0.27666873,  0.25106573,
               0.11094163,  0.10180622,  0.04633349,  0.02704855]])
docstr_tok: ["Computes","array","of","greyness","means",".","Corresponds","to","'step","3'","Args",":","image","(","numpy.ndarray",")",":","n","x","m","array","of","floats","--","the","greyscale","image",".","Typically",",","the","output","of","preprocess_image","x_coords","(","numpy.ndarray",")",":","array","of","row","numbers","y_coords","(","numpy.ndarray",")",":","array","of","column","numbers","P","(","Optional","[","int","]",")",":","size","of","boxes","in","pixels","(","default","None",")","Returns",":","an","N","x","N","array","of","average","greyscale","around","the","gridpoint",",","where","N","is","the","number","of","grid","points","Examples",":",">",">",">","img","=","gis.preprocess_image","(","'https",":","\/\/pixabay.com\/static\/uploads\/photo\/2012\/11\/28\/08\/56\/mona-lisa-67506_960_720.jpg","'",")",">",">",">","window","=","gis.crop_image","(","img",")",">",">",">","grid","=","gis.compute_grid_points","(","img",",","window=window",")",">",">",">","gis.compute_mean_level","(","img",",","grid","[","0","]",",","grid","[","1","]",")","array","(","[","[","0.62746325",",","0.62563642",",","0.62348078",",","0.50651686",",","0.37438874",",","0.0644063",",","0.55968952",",","0.59356148",",","0.60473832","]",",","[","0.35337797",",","0.50272543",",","0.27711346",",","0.42384226",",","0.39006181",",","0.16773968",",","0.10471924",",","0.33647144",",","0.62902124","]",",","[","0.20307514",",","0.19021892",",","0.12435402",",","0.44990121",",","0.38527996",",","0.08339507",",","0.05530059",",","0.18469107",",","0.21125228","]",",","[","0.25727387",",","0.1669419",",","0.08964046",",","0.1372754",",","0.48529236",",","0.39894004",",","0.10387907",",","0.11282135",",","0.30014612","]",",","[","0.23447867",",","0.15702549",",","0.25232943",",","0.75172715",",","0.79488688",",","0.4943538",",","0.29645163",",","0.10714578",",","0.0629376","]",",","[","0.22167555",",","0.04839472",",","0.10125833",",","0.1550749",",","0.14346914",",","0.04713144",",","0.10095568",",","0.15349296",",","0.04456733","]",",","[","0.09233709",",","0.11210942",",","0.05361996",",","0.07066566",",","0.04191625",",","0.03548839",",","0.03420656",",","0.05025029",",","0.03519956","]",",","[","0.19226873",",","0.20647194",",","0.62972106",",","0.45514529",",","0.05620413",",","0.03383168",",","0.03413588",",","0.04741828",",","0.02987698","]",",","[","0.05799523",",","0.23310153",",","0.43719717",",","0.27666873",",","0.25106573",",","0.11094163",",","0.10180622",",","0.04633349",",","0.02704855","]","]",")"]
code: def compute_mean_level(image, x_coords, y_coords, P=None):
      """Computes array of greyness means.
  
      Corresponds to 'step 3'
  
      Args:
          image (numpy.ndarray): n x m array of floats -- the greyscale image. Typically,
              the output of preprocess_image
          x_coords (numpy.ndarray): array of row numbers
          y_coords (numpy.ndarray): array of column numbers
          P (Optional[int]): size of boxes in pixels (default None)
  
      Returns:
          an N x N array of average greyscale around the gridpoint, where N is the
              number of grid points
  
      Examples:
          >>> img = gis.preprocess_image('https://pixabay.com/static/uploads/photo/2012/11/28/08/56/mona-lisa-67506_960_720.jpg')
          >>> window = gis.crop_image(img)
          >>> grid = gis.compute_grid_points(img, window=window)
          >>> gis.compute_mean_level(img, grid[0], grid[1])
          array([[ 0.62746325,  0.62563642,  0.62348078,  0.50651686,  0.37438874,
                   0.0644063 ,  0.55968952,  0.59356148,  0.60473832],
                 [ 0.35337797,  0.50272543,  0.27711346,  0.42384226,  0.39006181,
                   0.16773968,  0.10471924,  0.33647144,  0.62902124],
                 [ 0.20307514,  0.19021892,  0.12435402,  0.44990121,  0.38527996,
                   0.08339507,  0.05530059,  0.18469107,  0.21125228],
                 [ 0.25727387,  0.1669419 ,  0.08964046,  0.1372754 ,  0.48529236,
                   0.39894004,  0.10387907,  0.11282135,  0.30014612],
                 [ 0.23447867,  0.15702549,  0.25232943,  0.75172715,  0.79488688,
                   0.4943538 ,  0.29645163,  0.10714578,  0.0629376 ],
                 [ 0.22167555,  0.04839472,  0.10125833,  0.1550749 ,  0.14346914,
                   0.04713144,  0.10095568,  0.15349296,  0.04456733],
                 [ 0.09233709,  0.11210942,  0.05361996,  0.07066566,  0.04191625,
                   0.03548839,  0.03420656,  0.05025029,  0.03519956],
                 [ 0.19226873,  0.20647194,  0.62972106,  0.45514529,  0.05620413,
                   0.03383168,  0.03413588,  0.04741828,  0.02987698],
                 [ 0.05799523,  0.23310153,  0.43719717,  0.27666873,  0.25106573,
                   0.11094163,  0.10180622,  0.04633349,  0.02704855]])
  
      """
  
      if P is None:
          P = max(
              [2.0, int(0.5 + min(image.shape) / 20.0)]
          )  # per the paper
  
      avg_grey = np.zeros((x_coords.shape[0], y_coords.shape[0]))
  
      for i, x in enumerate(x_coords):  # not the fastest implementation
          lower_x_lim = int(max([x - P / 2, 0]))
          upper_x_lim = int(min([lower_x_lim + P, image.shape[0]]))
          for j, y in enumerate(y_coords):
              lower_y_lim = int(max([y - P / 2, 0]))
              upper_y_lim = int(min([lower_y_lim + P, image.shape[1]]))
  
              avg_grey[i, j] = np.mean(
                  image[
                      lower_x_lim:upper_x_lim, lower_y_lim:upper_y_lim
                  ]
              )  # no smoothing here as in the paper
  
      return avg_grey
  
imports: from skimage.color import rgb2gray
  from skimage.io import imread
  from PIL import Image
  from PIL.MpoImagePlugin import MpoImageFile
  from six import string_types, text_type
  from io import BytesIO
  import numpy
  import xml.etree
  import xml.etree.ElementTree
label_desc: Use image node_id 6 for calling the ImageSignature obj's underlying member method code with example usage: obj.compute_mean_level(image, x_coords, y_coords, P) and returns: avg_grey