DataWrapperFinal.py 文件源码

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

项目:EquationRecognition 作者: xyjiang94 项目源码 文件源码
def image_deformation(self,image):
        random_shear_angl = np.random.random() * np.pi/6 - np.pi/12
        random_rot_angl = np.random.random() * np.pi/6 - np.pi/12 - random_shear_angl
        random_x_scale = np.random.random() * .4 + .8
        random_y_scale = np.random.random() * .4 + .8
        random_x_trans = np.random.random() * image.shape[0] / 4 - image.shape[0] / 8
        random_y_trans = np.random.random() * image.shape[1] / 4 - image.shape[1] / 8
        dx = image.shape[0]/2. \
                - random_x_scale * image.shape[0]/2 * np.cos(random_rot_angl)\
                + random_y_scale * image.shape[1]/2 * np.sin(random_rot_angl + random_shear_angl)
        dy = image.shape[1]/2. \
                - random_x_scale * image.shape[0]/2 * np.sin(random_rot_angl)\
                - random_y_scale * image.shape[1]/2 * np.cos(random_rot_angl + random_shear_angl)
        trans_mat = AffineTransform(rotation=random_rot_angl,
                                    translation=(dx + random_x_trans,
                                                 dy + random_y_trans),
                                    shear = random_shear_angl,
                                    scale = (random_x_scale,random_y_scale))
        return warp(image,trans_mat.inverse,output_shape=image.shape)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号