def _remove_padding(path_to_image, output_path, padding):
"""
Removes padding of a single image and saves output to a new file
:param path_to_image: full path to an input image
:param output_path: full path to a file in which output result is saved
:param padding: integer
:return: nothing
"""
if not os.path.isfile(path_to_image):
print 'Warning: %s not found' % path_to_image
return
# read image
image = io.imread(path_to_image)
dim = image.shape
x = dim[0] - padding
y = dim[1] - padding
# crop the image
image_cropped = image[padding:x, padding:y]
# save cropped image
io.imsave(output_path, image_cropped)
评论列表
文章目录