Skip to main content

utils

Utility functions for visualisation.

Module

Functions

draw_registered_segmentation

def draw_registered_segmentation(    background: Image.Image,    segmentation: np.ndarray,    metadata: np.ndarray,    colour: Union[str, tuple[int, int, int]] = (255, 0, 0),    alpha: float = 0.3,    threshold: float = 0.7,)> PIL.Image.Image:

Visualise en-face image.

generate_slider

def generate_slider(    ga_metric: float,    filename: Optional[Union[str, os.PathLike]] = None,    total_ga_area_lower_bound: float = 2.5,    total_ga_area_upper_bound: float = 17.5,)> None:

Generates a slider for the GA metric.

Arguments

  • ga_metric: The value of the GA metric.
  • filename: The name of the file to save the slider to. Optional, defaults to "slider.png".
  • total_ga_area_lower_bound: The lower bound of the GA area. Optional, defaults to 2.5.
  • total_ga_area_upper_bound: The upper bound of the GA area. Optional, defaults to 17.5.

get_fovea_planar_coords

def get_fovea_planar_coords(    x: int, bscan_width: int, x_start: int, y_start: int, x_end: int, y_end: int,)> Coordinates:

Returns the planar coordinates of the fovea in the en-face image.

Arguments

  • x: The x coordinate of the fovea in the B-Scan.
  • bscan_width: The width of the bscan.
  • x_start: The x coordinate of the start of the bscan image.
  • y_start: The y coordinate of the start of the bscan image.
  • x_end: The x coordinate of the end of the bscan image.
  • y_end: The y coordinate of the end of the bscan image.

Returns The planar coordinates of the fovea in the en-face image.

overlay_with_alpha_layer

def overlay_with_alpha_layer(    img: Image.Image,    overlay: np.ndarray,    colour: Union[str, tuple[int, int, int]] = (255, 0, 0),    alpha: float = 0.3,)> PIL.Image.Image:

Overlay an image with a segmentation.

resize_and_threshold_enface

def resize_and_threshold_enface(    enface: np.ndarray, smoothing: int = 1, threshold: float = 0.7,)> numpy.ndarray[typing.Any, numpy.dtype[numpy.floating]]:

Resize en-face image prior to drawing segmentation and apply thresholding.

Resizes the input enface array to the expected size, applying smoothing to the width as desired.

Then applies thresholding to the array to produce an array of 1.0 or 0.0 indicating where the elements were greater than the threshold value.