Created
April 11, 2016 19:12
-
-
Save daviddao/f734b541a8c603df08206a7ab7062df3 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
''' | |
Takes an image in numpy format as input and returns a padded image | |
''' | |
def pad_image(image, output_shape): | |
x_pad = (output_shape[0] - image.shape[0]) / 2 | |
y_pad = (output_shape[1] - image.shape[1]) / 2 | |
resized = np.pad(image, ((x_pad,x_pad),(y_pad,y_pad)), mode='constant', constant_values=0) | |
return resized |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment