saliency.py 文件源码

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

项目:saliency-bms 作者: fzliu 项目源码 文件源码
def activate_boolean_map(bool_map):
    """
        Performs activation on a single boolean map.
    """

    # use the boolean map as a mask for flood filling
    activation = np.array(bool_map, dtype=np.uint8)
    mask_shape = (bool_map.shape[0] + 2, bool_map.shape[1] + 2)
    ffill_mask = np.zeros(mask_shape, dtype=np.uint8)

    # top and bottom rows
    for i in range(0, activation.shape[0]):
        for j in [0, activation.shape[1] - 1]:
            if activation[i,j]:
                cv2.floodFill(activation, ffill_mask, (j, i), 0)

    # left and right columns
    for i in [0, activation.shape[0] - 1]:
        for j in range(0, activation.shape[1]):
            if activation[i,j]:
                cv2.floodFill(activation, ffill_mask, (j, i), 0)

    return activation
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号