hough.py 文件源码

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

项目:computer-vision-algorithms 作者: aleju 项目源码 文件源码
def grad_magnitude(img):
    """Calculate the gradient magnitude of an image.
    Args:
        img The image
    Returns:
        gradient image"""
    img = img / 255.0
    sobel_y = np.array([
        [-1, -2, -1],
        [0, 0, 0],
        [1, 2, 1]
    ])
    sobel_x = np.rot90(sobel_y) # rotates counter-clockwise

    # apply x/y sobel filter to get x/y gradients
    imgx = signal.correlate(img, sobel_x, mode="same")
    imgy = signal.correlate(img, sobel_y, mode="same")
    imgmag = np.sqrt(imgx**2 + imgy**2)

    return imgmag
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号