biapol_utilities.label.match_labels

biapol_utilities.label.match_labels(label_image_x, label_image_y, metric_method=<function intersection_over_union_matrix>, filter_method=<function suppressed_similarity>, matching_method=<function match_gale_shapley>)

Match labels in label_image_y with labels in label_image_x.

Labels of two passed label images are evaluated regarding their similarity, whereas different metrics can be used for this. The labels from label_image_y are then matched up with the respective corresponding labels in label_image_x based on the chosen matching algorithm.

Parameters
  • label_image_x (nd-array) – Image that should serve as a reference for label-matching

  • label_image_y (nd-array) – Image the labels of which should be paired with labels from imageA

  • metric_method (callable, optional) – Method to be used to generate a metric of similarity between labels in subsequent slices. Must return a matrix with shape=(max(n, m), max(n, m)), where n and m are the present labels in two subsequent slices z and z+1. The values in the matrix must be normalized to a range of [0, 1], where 0 and signify minimal or maximal similarity between two labels. Default is intersection_over_union_matrix

  • filter_method (callable, optional) – Method to be used to filter values from the similarity matrix. This can help to speed up the matching process if, fo instance, entries in the similarity matrix below a defined threshold are set to zero. Default is suppressed_similarity(similiarity_matrix, threshold=0.3)

  • matching_method (callable, optional) – Method to be used for matching the labels. This function is supposed to return a binary matrix with shape=(n+1, m+1) corresponding to match=1, no_match=0 of the n labels in a given slice and m labels in the following slice. The default is match_max_similarity.

Returns

Processed version of label_image_y with labels corresponding to label_image_x.

Return type

nd-array