def mala_clustering(graph, edge_features, edge_sizes, threshold):
    n_nodes = graph.numberOfNodes
    policy = nagglo.malaClusterPolicy(graph=graph,
                                      edgeIndicators=edge_features,
                                      nodeSizes=np.zeros(n_nodes, dtype='float'),
                                      edgeSizes=edge_sizes,
                                      threshold=threshold)
    clustering = nagglo.agglomerativeClustering(policy)
    clustering.run()
    return clustering.result()
    def cluster(threshold):
        policy = nagglo.malaClusterPolicy(graph=graph,
                                          edgeIndicators=probs,
                                          edgeSizes=edge_sizes,
                                          nodeSizes=node_sizes,
                                          threshold=threshold)

        clustering = nifty.graph.agglo.agglomerativeClustering(policy)
        clustering.run()
        node_labels = clustering.result()
        return (node_labels[lifted_uvs[:, 0]] !=
                node_labels[lifted_uvs[:, 1]]).astype('float32')
示例#3
0
def mala_clustering(graph, edge_features, edge_sizes, threshold):
    """ Compute segmentation with mala-style clustering.

    Arguments:
        graph [nifty.graph] - graph to cluster
        edge_features [np.ndarray] - features used for clustering
        edge_sizes [np.ndarray] - sizes of edges
        threshold [float] - threshold to stop clustering
    """
    n_nodes = graph.numberOfNodes
    policy = nagglo.malaClusterPolicy(graph=graph,
                                      edgeIndicators=edge_features,
                                      nodeSizes=np.zeros(n_nodes,
                                                         dtype='float'),
                                      edgeSizes=edge_sizes,
                                      threshold=threshold)
    clustering = nagglo.agglomerativeClustering(policy)
    clustering.run()
    return clustering.result()
示例#4
0
def mala_clustering(graph, edge_features, edge_sizes, threshold):
    """ Compute segmentation with mala-style clustering.

    In "Large Scale Image Segmentation with Structured Loss based Deep Learning for Connectome Reconstruction":
    https://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=8364622

    Arguments:
        graph [nifty.graph] - graph to cluster
        edge_features [np.ndarray] - features used for clustering
        edge_sizes [np.ndarray] - sizes of edges
        threshold [float] - threshold to stop clustering
    """
    n_nodes = graph.numberOfNodes
    policy = nagglo.malaClusterPolicy(graph=graph,
                                      edgeIndicators=edge_features,
                                      nodeSizes=np.zeros(n_nodes,
                                                         dtype='float'),
                                      edgeSizes=edge_sizes,
                                      threshold=threshold)
    clustering = nagglo.agglomerativeClustering(policy)
    clustering.run()
    return clustering.result()
示例#5
0
 def _cluster_policy(self, graph, edge_features, node_sizes, edge_sizes):
     return nagglo.malaClusterPolicy(graph=graph,
                                     edgeIndicators=edge_features,
                                     nodeSizes=node_sizes,
                                     edgeSizes=edge_sizes,
                                     threshold=self.threshold)