show_images.py 文件源码

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

项目:CNNbasedMedicalSegmentation 作者: BRML 项目源码 文件源码
def sinus(image, strength):
    rows, cols = image.shape[0], image.shape[1]

    src_cols = np.linspace(0, cols, 5)
    src_rows = np.linspace(0, rows, 2)
    src_rows, src_cols = np.meshgrid(src_rows, src_cols)
    src = np.dstack([src_cols.flat, src_rows.flat])[0]

    # add sinusoidal oscillation to row coordinates
    dst_rows = src[:, 1] - np.sin(np.linspace(0, 2*np.pi, src.shape[0])) * strength 
    dst_cols = src[:, 0]
    dst_rows *= 1.
    dst_rows -= 1.5 * strength
    dst = np.vstack([dst_cols, dst_rows]).T


    tform = PiecewiseAffineTransform()
    tform.estimate(src, dst)

    out_rows = image.shape[0] #- 1.5 * 5
    out_cols = cols
    out = warp(image, tform, output_shape=(out_rows, out_cols))
    return np.array(out, dtype='float32')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号