tumourkit.preprocessing.png2graph.png2graph

tumourkit.preprocessing.png2graph.png2graph(img: ndarray, png: ndarray) DataFrame

Given an original image and a segmentation mask in PNG format, this function extracts the nodes and their attributes and returns them in a pandas DataFrame. The following attributes are computed for each node:

  • X: The X-coordinate of the centroid.

  • Y: The Y-coordinate of the centroid.

  • Area: The area of the cell.

  • Perimeter: The perimeter of the cell.

  • Variance: The variance of the grayscale values inside the cell.

  • Histogram: The normalized histogram of the grayscale values inside the cell (5 bins).

Parameters:
  • img (np.ndarray) – The original image as a numpy array.

  • png (np.ndarray) – The segmentation mask in PNG format as a numpy array.

Returns:

A pandas DataFrame containing the extracted nodes and their attributes.

Return type:

pd.DataFrame