simcats_datasets.support_functions.convert_lines

Helper functions for converting lines into different representations

@author: f.fuchs

Module Contents

Functions

lines_voltage_to_pixel_space

Convert lines from voltage space to image/pixel space.

lines_pixel_to_voltage_space

Convert lines from image/pixel space to voltage space.

lines_convert_two_coordinates_to_coordinate_plus_change

Change the format from x,y,x,y to x,y,dx,dy.

Module Implementation Details

simcats_datasets.support_functions.convert_lines.lines_voltage_to_pixel_space(lines, voltage_range_x, voltage_range_y, image_width, image_height, round_to_int=False)

Convert lines from voltage space to image/pixel space. This method makes a deepcopy of the supplied lines. Therefore, the original input won’t be modified.

Parameters:
  • lines (Union[List[numpy.ndarray], numpy.ndarray]) –

    Array or list of lines to convert, shape: (n, 4).

    Example:

    [[x_start, y_start, x_stop, y_stop], …]

  • voltage_range_x (numpy.ndarray) – Voltage range in x direction.

  • voltage_range_y (numpy.ndarray) – Voltage range in y direction.

  • image_width (int) – Width of the image/pixel space.

  • image_height (int) – Height of the image/pixel space.

  • round_to_int (bool) – Toggles if the lines are returned as floats (False) or are rounded and then returned as integers (True). Defaults to false.

Returns:

Array with rows containing the converted lines.

Return type:

numpy.ndarray

simcats_datasets.support_functions.convert_lines.lines_pixel_to_voltage_space(lines, voltage_range_x, voltage_range_y, image_width, image_height)

Convert lines from image/pixel space to voltage space. This method makes a deepcopy of the supplied lines. Therefore, the original input won’t be modified.

Parameters:
  • lines (Union[List[numpy.ndarray], numpy.ndarray]) –

    Array or list of lines to convert, shape: (n, 4).

    Example:

    [[x_start, y_start, x_stop, y_stop], …]

  • voltage_range_x (numpy.ndarray) – Voltage range in x direction.

  • voltage_range_y (numpy.ndarray) – Voltage range in y direction.

  • image_width (int) – Width of the image/pixel space.

  • image_height (int) – Height of the image/pixel space.

Returns:

Array with rows containing the converted lines.

Return type:

numpy.ndarray

simcats_datasets.support_functions.convert_lines.lines_convert_two_coordinates_to_coordinate_plus_change(lines)

Change the format from x,y,x,y to x,y,dx,dy. Order: top point > bottom point and if same y coordinate, right point > left point.

Parameters:

lines (Union[List[numpy.ndarray], numpy.ndarray]) –

Array or list of lines to convert, shape: (n, 4).

Example:

[[x_start, y_start, x_stop, y_stop], …]

Returns:

Array with rows of lines in x,y,dx,dy format.

Return type:

numpy.ndarray