atomicds.core.utils¶
Functions
|
Check if two bounding boxes overlap |
|
Convert a set of 2D points to polar coordinates with radius and angle. |
|
Update a pattern graph with new node data from a DataFrame object |
|
Normalize a file path string for use with pathlib. |
|
Rescale pixel dimensions to a new image shape. |
|
Check if two regions are horizontally overlapping |
|
Normalize radius in polar coordinates, then convert back to cartesian to get rescaled cartesian coordinates in image dimensions. |
- atomicds.core.utils.normalize_pixel_dimensions(points: ndarray[tuple[Any, ...], dtype[_ScalarT]], image_shape: tuple[int, int]) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]
Rescale pixel dimensions to a new image shape.
- Parameters:
points (NDArray) – Numpy array containing a list of points with columns width, height.
image_shape (tuple[int, int]) – Image shape.
- Returns:
Numpy array containing the rescaled points.
- Return type:
NDArray
- atomicds.core.utils.boxes_overlap(box1, box2) bool[source]
Check if two bounding boxes overlap
- Parameters:
box1 (list[float]) – List of xmin, ymin, xmax, ymax coordinates defining first box
box2 (list[float]) – List of xmin, ymin, xmax, ymax coordinates defining second box
- Returns:
True if the boxes overlap
- Return type:
(bool)
- atomicds.core.utils.regions_horizontal_overlapping(node_df: DataFrame, start_node: int, end_node: int) bool[source]
Check if two regions are horizontally overlapping
- Parameters:
node_df (
DataFrame)start_node (
int)end_node (
int)
- Return type:
bool
- atomicds.core.utils.rescale_cartesian_coordinates(points: ndarray[tuple[Any, ...], dtype[_ScalarT]], origin=(0, 0), scale: float = 1.0) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]
Normalize radius in polar coordinates, then convert back to cartesian to get rescaled cartesian coordinates in image dimensions. :type points:
ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]] :param points: Numpy array containing a list of points. :type points: NDArray :type origin: :param origin: Origin point. :type origin: tuple[int, int] :type scale:float:param scale: Scaling number. :type scale: float- Returns:
Numpy array containing the rescaled points.
- Return type:
NDArray
- atomicds.core.utils.convert_to_polar_coordinates(points: ndarray[tuple[Any, ...], dtype[_ScalarT]], origin=(0, 0), scale=1.0) ndarray[tuple[Any, ...], dtype[_ScalarT]][source]
Convert a set of 2D points to polar coordinates with radius and angle.
- Parameters:
points (NDArray) – Numpy array containing a list of points.
origin (tuple[int, int]) – Origin point.
scale (float) – Scaling number.
- Return type:
ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]
- atomicds.core.utils.generate_graph_from_nodes(node_df: DataFrame) Graph[source]
Update a pattern graph with new node data from a DataFrame object
- Parameters:
node_df (
DataFrame)- Return type:
Graph
- atomicds.core.utils.normalize_path(path_str: str) Path[source]
Normalize a file path string for use with pathlib.
- This will:
Remove control characters and convert “smart” quotes into plain quotes.
Strip leading/trailing whitespace and any surrounding quotes.
Expand user (~) and environment variables.
Normalize Unicode, unify separators, and collapse “..”/“.” segments.
- Parameters:
path_str (
str) – Raw path string copied from Windows (may contain spaces, smart quotes, stray control chars, etc.)- Return type:
Path- Returns:
A pathlib.Path pointing to the normalized path.