dsb_image.py 文件源码

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

项目:data-science-bowl-2017 作者: tondonia 项目源码 文件源码
def augment_multi(images,random_flip_x,shift_x,shift_y,rotation_degrees,zoom_factor):
    pixels = images[0].shape[2]
    center = pixels/2.-0.5

    for i in range(len(images)):
        image = images[i]

        if random_flip_x:
            print "flipping image"
            #image[:,:] = image[:,::-1]
            image[:,:,:] = image[:,:,::-1] #original
        print image.shape
        if rotation_degrees != 0:
            print "rotating images"
            if i == 0: #lung
                image = rotate(image, rotation_degrees, axes=(1,2), reshape=False,cval=-3000,order=0)
            else:
                image = rotate(image, rotation_degrees, axes=(1,2), reshape=False,order=0)
            print "post rotate ",image.shape
            image = crop_or_pad_multi(image, pixels, -3000)
        print image.shape
        if shift_x != 0 or shift_y != 0:
            print "shifting images by ",shift_x,shift_y, image.shape
            if i == 0:
                image = shift(image, [0,shift_x,shift_y],order=0,cval=-3000)
            else:
                image = shift(image, [0,shift_x,shift_y],order=0)
        images[i] = image

    return images
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号