stafflines.py 文件源码

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

项目:muscima 作者: hajicj 项目源码 文件源码
def staffline_surroundings_mask(staffline_cropobject):
    """Find the parts of the staffline's bounding box which lie
    above or below the actual staffline.

    These areas will be very small for straight stafflines,
    but might be considerable when staffline curvature grows.
    """
    # We segment both masks into "above staffline" and "below staffline"
    # areas.
    elevation = staffline_cropobject.mask * 255
    # Blur, to plug small holes somewhat:
    elevation = gaussian(elevation, sigma=1.0)
    # Prepare the segmentation markers: 1 is ABOVE, 2 is BELOW
    markers = numpy.zeros(staffline_cropobject.mask.shape)
    markers[0, :] = 1
    markers[-1, :] = 2
    markers[staffline_cropobject.mask != 0] = 0
    seg = watershed(elevation, markers)

    bmask = numpy.ones(seg.shape)
    bmask[seg != 2] = 0
    tmask = numpy.ones(seg.shape)
    tmask[seg != 1] = 0

    return bmask, tmask


##############################################################################
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号