code: def binarizing(img,threshold):
      
      pixdata = img.load()
      w, h = img.size
      for y in range(h):
          for x in range(w):
              if pixdata[x, y] < threshold:
                  pixdata[x, y] = 0
              else:
                  pixdata[x, y] = 255
      return img
docs: 二值化
      :param img:
      :param threshold:
      :return: