How to use the stardist.Rays_GoldenSpiral function in stardist

To help you get started, we’ve selected a few stardist examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mpicbg-csbd / stardist / tests / test_nms3D.py View on Github external
def test_nms(n_rays, nms_thresh):
    dist = 10*np.ones((33,44,55,n_rays))
    prob = np.random.uniform(0,1,dist.shape[:3])
    rays = Rays_GoldenSpiral(dist.shape[-1])
    
    points, probi, disti = non_maximum_suppression_3d(dist, prob, rays,
                                                      prob_thresh=0.9,
                                                      nms_thresh = nms_thresh,
                                                      verbose=True)
    return points, rays, disti
github mpicbg-csbd / stardist / tests / test_stardist3D.py View on Github external
def test_types(img, n_rays, grid):
    mode = "cpp"
    rays = Rays_GoldenSpiral(n_rays)
    gt = star_dist3D(img, rays=rays, grid=grid, mode=mode)
    for dtype in (np.int8, np.int16, np.int32,
                  np.uint8, np.uint16, np.uint32):
        x = star_dist3D(img.astype(dtype), rays=rays, grid=grid, mode=mode)
        print("test_stardist3D (mode {mode}) for shape {img.shape} and type {dtype}".format(mode =mode, img = img, dtype = dtype))
        check_similar(gt, x)
github mpicbg-csbd / stardist / tests / test_stardist3D.py View on Github external
def test_types_gpu(img, n_rays, grid):
    mode = "opencl"
    rays = Rays_GoldenSpiral(n_rays)
    gt = star_dist3D(img, rays=rays, grid=grid, mode=mode)
    for dtype in (np.int8, np.int16, np.int32,
                  np.uint8, np.uint16, np.uint32):
        x = star_dist3D(img.astype(dtype), rays=rays, grid=grid, mode=mode)
        print("test_stardist3D (mode {mode}) for shape {img.shape} and type {dtype}".format(mode =mode, img = img, dtype = dtype))
        check_similar(gt, x)
github mpicbg-csbd / stardist / tests / test_nms3D.py View on Github external
def test_label():
    n_rays = 32 
    dist = 20*np.ones((1,n_rays))
    rays = Rays_GoldenSpiral(dist.shape[-1])
    points = [[20,20,20]]
    return polyhedron_to_label(dist,points, rays, shape = (33,44,55))
github mpicbg-csbd / stardist / tests / test_stardist3D.py View on Github external
@pytest.mark.gpu
@pytest.mark.parametrize('img', (real_image3d()[1], random_image((33, 44, 55))))
@pytest.mark.parametrize('n_rays', (4, 16, 32))
@pytest.mark.parametrize('grid', ((1,1,1),(1,2,4)))
def test_cpu_gpu(img, n_rays, grid):
    rays = Rays_GoldenSpiral(n_rays)
    s_cpp = star_dist3D(img, rays=rays, grid=grid, mode="cpp")
    s_ocl = star_dist3D(img, rays=rays, grid=grid, mode="opencl")
    check_similar(s_cpp, s_ocl)


if __name__ == '__main__':
    from utils import circle_image

    rays = Rays_GoldenSpiral(4)
    lbl = circle_image((64,) * 3)

    a = star_dist3D(lbl, rays=rays, grid=(1, 2, 2), mode="cpp")
    b = star_dist3D(lbl, rays=rays, grid=(1, 2, 2), mode="opencl")
    print(np.amax(np.abs(a - b)))
github mpicbg-csbd / stardist / tests / test_stardist3D.py View on Github external
def test_cpu_gpu(img, n_rays, grid):
    rays = Rays_GoldenSpiral(n_rays)
    s_cpp = star_dist3D(img, rays=rays, grid=grid, mode="cpp")
    s_ocl = star_dist3D(img, rays=rays, grid=grid, mode="opencl")
    check_similar(s_cpp, s_ocl)