image_segmentation module

calculate_distance(x1, y1, x2, y2)[source]

Calculate the Euclidean distance between two points.

Authors: Ethan Fang Version: v0_1 (Jul 10 2023)

Parameters:
  • x1 (float) – X-coordinate of the first point.

  • y1 (float) – Y-coordinate of the first point.

  • x2 (float) – X-coordinate of the second point.

  • y2 (float) – Y-coordinate of the second point.

Returns:

The Euclidean distance between the two points.

Return type:

float

find_clusters(df, number_cluster=15)[source]

Find clusters in the given DataFrame using K-means clustering.

Authors: Ethan Fang Version: v0_1 (Jul 10 2023)

Parameters:
  • df (pandas.DataFrame) – The DataFrame containing the coordinates and intensities of the pixels.

  • number_cluster (int, optional) – The number of clusters to find, defaults to 15.

Returns:

The DataFrame with an additional ‘Cluster’ column indicating the cluster label for each pixel.

Return type:

pandas.DataFrame

find_ring_coordinates(image_path, percent=0.15)[source]

Find the coordinates of pixels with the highest intensities in an image.

Authors: Ethan Fang Version: v0_1 (Jul 10 2023)

Parameters:
  • image_path (str) – The path to the input image file.

  • percent (float, optional) – The percentage of pixels to consider, defaults to 0.15.

Returns:

A DataFrame containing the coordinates and intensities of the selected pixels.

Return type:

pandas.DataFrame

process_image(image_path, percent=0.15, number_cluster=15)[source]

Completely process image from path to obtain dataframe of information about rings and datapoints.

Authors: Ethan Fang Version: v0_1 (Jul 10 2023)

Parameters:
  • image_path (str) – The path to the input image file.

  • percent (float, optional) – The percentage of pixels to consider, defaults to 0.15.

  • number_cluster (int, optional) – The number of clusters to find, defaults to 15.

Returns:

The DataFrame with the processed results.

Return type:

pandas.DataFrame