image_to_similarity_graph#

tangles.util.graph.similarity.image_to_similarity_graph(image: ndarray, pixel_coord_distance_graph: csr_array, sigma_c: float = 0.2, sigma_d: float = 3, threshold: float = 0.01, color_sim_p=1)#

Computes a similarity graph for pixels of an image.

Uses a graph to describe the differences between the pixel coordinates and then uses a gaussian function to calculate the similarity from this distance. A gaussian function is also used for color similarity by applying it to the sum of the absolute values of the differences in color channels.

Parameters#

imagenp.ndarray

An image, either a (width, height, 3) or (width, height, 1) grayscale image.

pixel_coord_distance_graphsparse.csr_array

A sparse matrix containing the distances between pixel coordinates.

sigma_cfloat

The spread of the gaussian function used for the similarity calculation of the color value.

sigma_dfloat

The spread of the gaussian function used for the similarity calculation of the distance value.

thresholdfloat

Edges below this value get removed in the resultant similarity graph.

Returns#

sprase.csr_array

A sparse similarity graph between pixels of the image.