sv_candidates.py 文件源码

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

项目:grocsvs 作者: grocsvs 项目源码 文件源码
def get_svs(mat, bg_mat, sv_region, window_size, rolling=0):
    if rolling > 0:
        weights = numpy.ones((rolling*2+1, rolling*2+1))    
        mat = ndimage.convolve(mat, weights, mode="constant")
        bg_mat = ndimage.convolve(bg_mat, weights, mode="constant")

    norm = mat/bg_mat
    norm[numpy.isnan(norm)] = 0
    norm = numpy.ma.masked_array(norm, mask=False)

    breakpoints = []

    while not norm.mask.all():
        where = numpy.ma.where(norm==norm.max())
        where = (where[0][0], where[1][0])

        is_good = (mat[where] > 25 and norm[where] > 0.05)

        if is_good:
            breakpoint = (where[1]*window_size + sv_region["startx"],
                          where[0]*window_size + sv_region["starty"])

            breakpoints.append(breakpoint)

            # TODO: constant for extend; this determines the closest
            # any two breakpoints can be from one another
            norm.mask[get_matrix_rect(norm, where, 10)] = True
        else:
            break

    return breakpoints
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号