Exemplo n.º 1
0
def test_linear_warp_polar():
    radii = [5, 10, 15, 20]
    image = np.zeros([51, 51])
    for rad in radii:
        rr, cc, val = circle_perimeter_aa(25, 25, rad)
        image[rr, cc] = val
    warped = warp_polar(image, radius=25)
    profile = warped.mean(axis=0)
    peaks = peak_local_max(profile)
    assert np.alltrue([peak in radii for peak in peaks])
Exemplo n.º 2
0
def test_linear_warp_polar():
    radii = [5, 10, 15, 20]
    image = cp.zeros([51, 51])
    for rad in radii:
        rr, cc, val = circle_perimeter_aa(25, 25, rad)
        image[rr, cc] = val
    warped = warp_polar(image, radius=25)
    profile = warped.mean(axis=0)
    # TODO: grlee77: peak_local_max.  For now, transfer to CPU to use
    #                peak_local_max (not yet implemented for GPU)
    peaks = peak_local_max(profile.get())
    assert np.alltrue([peak in radii for peak in peaks])
Exemplo n.º 3
0
def test_linear_warp_polar(dtype):
    radii = [5, 10, 15, 20]
    image = np.zeros([51, 51])
    for rad in radii:
        rr, cc, val = circle_perimeter_aa(25, 25, rad)
        image[rr, cc] = val
    image = image.astype(dtype, copy=False)
    warped = warp_polar(image, radius=25)
    assert warped.dtype == _supported_float_type(dtype)
    profile = warped.mean(axis=0)
    peaks = peak_local_max(profile)
    assert np.alltrue([peak in radii for peak in peaks])
Exemplo n.º 4
0
def test_log_warp_polar():
    radii = [np.exp(2), np.exp(3), np.exp(4), np.exp(5),
             np.exp(5)-1, np.exp(5)+1]
    radii = [int(x) for x in radii]
    image = np.zeros([301, 301])
    for rad in radii:
        rr, cc, val = circle_perimeter_aa(150, 150, rad)
        image[rr, cc] = val
    warped = warp_polar(image, radius=200, scaling='log')
    profile = warped.mean(axis=0)
    peaks_coord = peak_local_max(profile)
    peaks_coord.sort(axis=0)
    gaps = peaks_coord[1:] - peaks_coord[:-1]
    assert np.alltrue([x >= 38 and x <= 40 for x in gaps])
Exemplo n.º 5
0
def test_log_warp_polar():
    radii = [
        np.exp(2),
        np.exp(3),
        np.exp(4),
        np.exp(5),
        np.exp(5) - 1,
        np.exp(5) + 1,
    ]
    radii = [int(x) for x in radii]
    image = cp.zeros([301, 301])
    for rad in radii:
        rr, cc, val = circle_perimeter_aa(150, 150, rad)
        image[rr, cc] = val
    warped = warp_polar(image, radius=200, scaling="log")
    profile = warped.mean(axis=0)
    # TODO: grlee77: peak_local_max.  For now, transfer to CPU to use
    #                peak_local_max (not yet implemented for GPU)
    peaks_coord = peak_local_max(profile.get())
    peaks_coord.sort(axis=0)
    gaps = peaks_coord[1:] - peaks_coord[:-1]
    assert np.alltrue([x >= 38 and x <= 40 for x in gaps])