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: str | tuple[int, int, int] = (255, 0, 0),    alpha: float = 0.3,    threshold: float = 0.7,) ‑> PIL.Image.Image:

Visualise en-face image.

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: 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.