Created
July 9, 2018 18:22
-
-
Save jenkspt/b89ff327ab0696c791fd91a394b6f8f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def crop_center(image, crop_size): | |
""" Crops the central region of the image with shape crop_size""" | |
shape = image.shape | |
start0 = shape[0]//2-(crop_size[0]//2) | |
start1 = shape[1]//2-(crop_size[1]//2) | |
return img[start0:start0+crop_size[0],start1:start1+crop_size[1]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment