def flip(images, flips):
"""
Flips images based on the calculations from get_flips()
:param images: Either a single n-dimensional image as a numpy array or a list of them.
The images to flip
:param flips: The output from get_flips(), tells the function which axes to flip the images along
All images will be flipped the same way
:return: Either a single flipped copy of the input image, or a list of them in the same order that they
were passed in, depending on whether the 'images' parameter was a single picture or a list
"""
if isinstance(images, (list, tuple)):
return_list = True
image_list = images
else:
return_list = False
image_list = [images]
out = []
for img in image_list:
# probably the most I've type 'flip' in my life
flipped = img
for flip_axis in flips:
flipped = np.flip(flipped, flip_axis)
out.append(flipped.copy())
if return_list:
return out
else:
return out[0]
评论列表
文章目录