code: def re_size(image, factor=1):
      
      if factor < 1:
          raise ValueError('scaling factor in re-sizing %s < 1' %factor)
      f = int(factor)
      nx, ny = np.shape(image)
      if int(nx/f) == nx/f and int(ny/f) == ny/f:
          small = image.reshape([int(nx/f), f, int(ny/f), f]).mean(3).mean(1)
          return small
      else:
          raise ValueError("scaling with factor %s is not possible with grid size %s, %s" %(f, nx, ny))
docs: resizes image with nx x ny to nx/factor x ny/factor
      :param image: 2d image with shape (nx,ny)
      :param factor: integer >=1
      :return: