def rotate_crop(centerij, sz, angle, img=None, mode='<STR_LIT>', **kwargs):
<EOL>from skimage import transform<EOL>sz = np.array(sz)<EOL>crop_half = int(np.ceil(np.sqrt(np.square(sz).sum())))<EOL>if centerij[<NUM_LIT:0>] >= crop_half or centerij[<NUM_LIT:1>] >= crop_half:<EOL><INDENT>raise NotImplementedError<EOL><DEDENT>slicei = slice(centerij[<NUM_LIT:0>] - crop_half, centerij[<NUM_LIT:0>] + crop_half)<EOL>slicej = slice(centerij[<NUM_LIT:1>] - crop_half, centerij[<NUM_LIT:1>] + crop_half)<EOL>def _rotate_cropcenter(im):<EOL><INDENT>enoughcrop = im[slicei, slicej]<EOL>rotated = transform.rotate(enoughcrop, angle, resize=False, preserve_range=True, mode=mode, **kwargs)<EOL>return cropcenter(sz, rotated)<EOL><DEDENT>if img is not None:<EOL><INDENT>return _rotate_cropcenter(img)<EOL><DEDENT>return _rotate_cropcenter<EOL>
rotate and crop
if no img, then return crop function
:param centerij:
:param sz:
:param angle:
:param img: [h,w,d]
:param mode: padding option
:return: cropped image or function