Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import numpy as np
from stardist import non_maximum_suppression
n=128
prob = np.random.uniform(0,1,(n,n))
coord = np.random.uniform(0,10,(n,n,2,32))
inds = non_maximum_suppression(coord, prob, nms_thresh =.3)
inds = non_maximum_suppression(coord, prob, nms_thresh =.5)
inds = non_maximum_suppression(coord, prob, nms_thresh =.7)
def test_bbox_search(img):
prob = edt_prob(img)
dist = star_dist(img, n_rays=32, mode="cpp")
coord = dist_to_coord(dist)
nms_a = non_maximum_suppression(coord, prob, prob_thresh=0.4, verbose=False, max_bbox_search=False)
nms_b = non_maximum_suppression(coord, prob, prob_thresh=0.4, verbose=False, max_bbox_search=True)
check_similar(nms_a, nms_b)
def test_bbox_search(img):
prob = edt_prob(img)
dist = star_dist(img, n_rays=32, mode="cpp")
coord = dist_to_coord(dist)
nms_a = non_maximum_suppression(coord, prob, prob_thresh=0.4, verbose=False, max_bbox_search=False)
nms_b = non_maximum_suppression(coord, prob, prob_thresh=0.4, verbose=False, max_bbox_search=True)
check_similar(nms_a, nms_b)
def test_acc(img):
prob = edt_prob(img)
dist = star_dist(img, n_rays=32, mode="cpp")
coord = dist_to_coord(dist)
points = non_maximum_suppression(coord, prob, prob_thresh=0.4)
img2 = polygons_to_label(coord, prob, points, shape=img.shape)
m = matching(img, img2)
acc = m.accuracy
print("accuracy {acc:.2f}".format(acc=acc))
assert acc > 0.9