Exemplo n.º 1
0
def test_nms_accuracy(noise, n_rays):
    dx = 3
    shape = (40, 55, 66)
    rays = Rays_GoldenSpiral(n_rays)
    dist = 10 * (1 + noise * np.sin(2 * np.pi * rays.vertices[:, :2].T))
    points = [(20, 20, 20), (20, 20, 20 + dx)]
    mask1 = polyhedron_to_label([dist[0]], [points[0]], rays, shape=shape)
    mask2 = polyhedron_to_label([dist[1]], [points[1]], rays, shape=shape)
    iou = np.count_nonzero(mask1 * mask2) / min(
        np.count_nonzero(mask1),
        np.count_nonzero(mask2) + 1e-10)
    prob = [1, .5]
    print("iou =", iou)
    sup1 = non_maximum_suppression_3d_sparse(dist,
                                             prob,
                                             points,
                                             rays=rays,
                                             nms_thresh=0.95 * iou,
                                             verbose=True)[0]

    sup2 = non_maximum_suppression_3d_sparse(dist,
                                             prob,
                                             points,
                                             rays=rays,
                                             nms_thresh=1.05 * iou,
                                             verbose=True)[0]
    assert len(sup1) == 1 and len(sup2) == 2
    return mask1, mask2
Exemplo n.º 2
0
def test_rays_volume_area(n_rays=187):
    from skimage.measure import regionprops
    from skimage.segmentation import find_boundaries

    rays = Rays_GoldenSpiral(n_rays)
    shape = (55, 56, 58)
    center = np.array(shape) // 2

    dist = .4 * np.random.uniform(.3 * np.min(shape), .5 * np.min(shape),
                                  n_rays)

    lbl = polyhedron_to_label([dist], [center], rays=rays, shape=shape)

    volume1 = rays.volume(dist)
    volume2 = np.mean(rays.volume(np.broadcast_to(dist,
                                                  (13, 17) + dist.shape)))
    volume3 = regionprops(lbl)[0].area

    surface1 = rays.surface(dist)
    surface2 = np.mean(
        rays.surface(np.broadcast_to(dist, (13, 17) + dist.shape)))
    surface3 = np.sum(find_boundaries(lbl, mode="outer"))

    print(volume1, volume2, volume3)
    print(surface1, surface2, surface3)
    return lbl
Exemplo n.º 3
0
def test_nms_and_label(nms_thresh=0.1, shape=(33, 44, 55), noise=.1, n_rays=32):
    points, probi, disti, rays = create_random_suppressed(
        nms_thresh, shape=shape, noise=noise, n_rays=n_rays)
    lbl = polyhedron_to_label(disti, points, rays, shape=shape)
    return lbl
Exemplo n.º 4
0
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))
Exemplo n.º 5
0
def test_nms_and_label():
    points, rays, disti = test_nms()
    lbl = polyhedron_to_label(disti, points, rays, shape=(33, 44, 55))
    return lbl
Exemplo n.º 6
0
def test_nms_and_label(n_rays=32, nms_thresh=0.1):
    points, rays, disti = test_nms(n_rays, nms_thresh)
    lbl = polyhedron_to_label(disti, points, rays, shape=(33, 44, 55))
    return lbl