Exemple #1
0
def test_circle_se():
    from mahotas.morph import circle_se
    for r in (4, 5):
        c = circle_se(r)
        assert len(c) == (2 * r + 1)
        assert len(c) == len(c.T)
        assert not c.all()
        assert c.any()

    with pytest.raises(ValueError):
        circle_se(-1)
Exemple #2
0
def bernsen(f, radius, contrast_threshold, gthresh=None):
    '''
    thresholded = bernsen(f, radius, contrast_threshold, gthresh={128})

    Bernsen local thresholding

    Parameters
    ----------
    f : ndarray
        input image
    radius : integer
        radius of circle (to consider "local")
    contrast_threshold : integer
        contrast threshold
    gthresh : numeric, optional
        global threshold to fall back in low contrast regions

    Returns
    -------
    thresholded : binary ndarray

    See Also
    --------
    gbernsen : function
        Generalised Bernsen thresholding
    '''
    from mahotas.morph import circle_se
    if gthresh is None:
        gthresh = 128
    return gbernsen(f, circle_se(radius), contrast_threshold, gthresh)
Exemple #3
0
def bernsen(f, radius, contrast_threshold, gthresh=None):
    '''
    thresholded = bernsen(f, radius, contrast_threshold, gthresh={128})

    Bernsen local thresholding

    Parameters
    ----------
    f : ndarray
        input image
    radius : integer
        radius of circle (to consider "local")
    contrast_threshold : integer
        contrast threshold
    gthresh : numeric, optional
        global threshold to fall back in low contrast regions

    Returns
    -------
    thresholded : binary ndarray

    See Also
    --------
    gbernsen : function
        Generalised Bernsen thresholding
    '''
    from mahotas.morph import circle_se
    if gthresh is None:
        gthresh = 128
    return gbernsen(f, circle_se(radius), contrast_threshold, gthresh)
def test_circle_se():
    from mahotas.morph import circle_se
    for r in (4,5):
        c = circle_se(r)
        assert len(c) == (2*r + 1)
        assert len(c) == len(c.T)
        assert not c.all()
        assert c.any()

    @raises(ValueError)
    def circle_1():
        circle_se(-1)
    circle_1()
Exemple #5
0
 def circle_1():
     circle_se(-1)
 def circle_1():
     circle_se(-1)