def cropcenter(sz, img=None):
l = len(sz)<EOL>sz = np.array(sz)<EOL>def wrapped(im):<EOL><INDENT>imsz = np.array(im.shape)<EOL>s = (imsz[:l] - sz) / <NUM_LIT:2>  <EOL>to = s + sz  <EOL>slices = [slice(s, e) for s, e in zip(s, to)]<EOL>return im[slices]<EOL><DEDENT>if img is not None:<EOL><INDENT>return wrapped(img)<EOL><DEDENT>return wrapped<EOL>
if no img, then return crop function
:param sz:
:param img:
:return: