flip.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:pytorch_fnet 作者: AllenCellModeling 项目源码 文件源码
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]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号