edge_canny_get_orientation_sector.py 文件源码

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

项目:Image-Processing-Algorithms 作者: machinelearninggod 项目源码 文件源码
def get_orientation_sector(dx,dy):
    # rotate (dx,dy) by pi/8
    rotation = np.array([[np.cos(np.pi/8), -np.sin(np.pi/8)],
                          [np.sin(np.pi/8), np.cos(np.pi/8)]])
    rotated = np.dot(rotation, np.array([[dx], [dy]]))

    if rotated[1] < 0:
        rotated[0] = -rotated[0]
        rotated[1] = -rotated[1]

    s_theta = -1
    if rotated[0] >= 0 and rotated[0] >= rotated[1]:
        s_theta = 0
    elif rotated[0] >= 0 and rotated[0] < rotated[1]:
        s_theta = 1
    elif rotated[0] < 0 and -rotated[0] < rotated[1]:
        s_theta = 2
    elif rotated[0] < 0 and -rotated[0] >= rotated[1]:
        s_theta = 3

    return s_theta
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号