dodal.devices.oav.beam_centre.beam_centre#

Classes

CentreEllipseMethod

Upon triggering, fits an ellipse to a binary image from the area detector defined by the prefix.

Functions

convert_image_to_binary(image)

Creates a binary image from OAV image array data.

get_roi(image_arr, centre_x, centre_y[, ...])

Creates an ROI image array from a full screen image array, given a centre for the ROI image and a width and height of the ROI box.

round_half_up(x)

dodal.devices.oav.beam_centre.beam_centre.convert_image_to_binary(image: ndarray)[source]#

Creates a binary image from OAV image array data.

Pixels of the input image are converted to one of two values (a high and a low value). Otsu’s method is used for automatic thresholding. See https://docs.opencv.org/4.x/d7/d4d/tutorial_py_thresholding.html. The threshold is increased by ADDITIONAL_BINARY_THRESH in order to get more of the centre of the beam.

Parameters:

image (ndarray)

dodal.devices.oav.beam_centre.beam_centre.round_half_up(x)[source]#
dodal.devices.oav.beam_centre.beam_centre.get_roi(image_arr: ndarray, centre_x: int, centre_y: int, box_width: int = 200, box_height: int = 200) tuple[ndarray, tuple[int, int], tuple[int, int]][source]#

Creates an ROI image array from a full screen image array, given a centre for the ROI image and a width and height of the ROI box. Note that if the centre of the ROI box is close to the edge of the full screen image, the box may be smaller than the width and height provided, as the ROI will be trimmed to fit inside the full screen image.

Parameters:
  • image_arr (np.ndarray) – The full screen image array.

  • centre_x (int) – The x coordinate of the centre of the ROI box.

  • centre_y (int) – The y coordinate of the centre of the ROI box.

  • box_width (int, optional) – The width of the ROI box. Defaults to 200.

  • box_height (int, optional) – The height of the ROI box. Defaults to 200.

Returns:

The ROI array, and (x, y)

coordinates of the top left and bottom right corners of the ROI box.

Return type:

tuple[np.ndarray, tuple[int, int], tuple[int, int]]