Пример #1
0
def cluster_centroids(centroids, displacement, thres=2.5):
    # thres: threshold for grouping centroid (see supp)

    dp_strength = np.sqrt(displacement[1] ** 2 + displacement[0] ** 2)
    height, width = dp_strength.shape

    weak_dp_region = dp_strength < thres

    dp_label = skimage.measure.label(weak_dp_region, connectivity=1, background=0)
    dp_label_1d = dp_label.reshape(-1)

    centroids_1d = centroids[0]*width + centroids[1]

    clusters_1d = dp_label_1d[centroids_1d]

    cluster_map = imutils.compress_range(clusters_1d.reshape(height, width) + 1)

    return pyutils.to_one_hot(cluster_map)
Пример #2
0
def cluster_centroids(centroids, displacement, thres):

    dp_strength = np.sqrt(displacement[1]**2 + displacement[0]**2)
    height, width = dp_strength.shape

    weak_dp_region = dp_strength < thres

    dp_label = skimage.measure.label(weak_dp_region, neighbors=4, background=0)
    dp_label_1d = dp_label.reshape(-1)

    centroids_1d = centroids[0] * width + centroids[1]

    clusters_1d = dp_label_1d[centroids_1d]

    cluster_map = imutils.compress_range(
        clusters_1d.reshape(height, width) + 1)

    return pyutils.to_one_hot(cluster_map)