code: def quantize_without_scipy(self, image):
           This function can be used if no scipy is availabe.
          It's 7 times slower though.
          """
          w, h = image.size
          px = np.asarray(image).copy()
          memo = {}
          for j in range(w):
              for i in range(h):
                  key = (px[i, j, 0], px[i, j, 1], px[i, j, 2])
                  try:
                      val = memo[key]
                  except KeyError:
                      val = self.convert(*key)
                      memo[key] = val
                  px[i, j, 0], px[i, j, 1], px[i, j, 2] = val
          return Image.fromarray(px).convert("RGB").quantize(palette=self.palette_image())
docs: This function can be used if no scipy is availabe.
          It's 7 times slower though.