Skip to content

webknossos.geometry.bounding_box

#   class BoundingBox:

This class is used to represent an axis-aligned cuboid in 3D. The top-left coordinate is inclusive and the bottom-right coordinate is exclusive.

A small usage example:

from webknossos import BoundingBox

bbox_1 = BoundingBox((0, 0, 0), (100, 100, 100))
bbox_2 = BoundingBox((75, 75, 75), (100, 100, 100))

assert bbox_1.intersected_with(bbox_2).size == (25, 25, 25)
#   BoundingBox( topleft: Union[int, Union[webknossos.geometry.vec3_int.Vec3Int, Tuple[int, int, int], numpy.ndarray, Iterable[int]]], size: Union[int, Union[webknossos.geometry.vec3_int.Vec3Int, Tuple[int, int, int], numpy.ndarray, Iterable[int]]], name: Union[str, NoneType] = 'Unnamed Bounding Box', is_visible: bool = True, id: Union[str, NoneType] = None, color: Union[Tuple[float, float, float, float], NoneType] = None )

Method generated by attrs for class BoundingBox.

#   name: Union[str, NoneType]
#   is_visible: bool
#   id: Union[str, NoneType]
#   color: Union[Tuple[float, float, float, float], NoneType]
#   def with_topleft( self, new_topleft: Union[webknossos.geometry.vec3_int.Vec3Int, Tuple[int, int, int], numpy.ndarray, Iterable[int]] ) -> webknossos.geometry.bounding_box.BoundingBox:
#   def with_size( self, new_size: Union[webknossos.geometry.vec3_int.Vec3Int, Tuple[int, int, int], numpy.ndarray, Iterable[int]] ) -> webknossos.geometry.bounding_box.BoundingBox:
#   def with_bounds_x( self, new_topleft_x: Union[int, NoneType] = None, new_size_x: Union[int, NoneType] = None ) -> webknossos.geometry.bounding_box.BoundingBox:

Returns a copy of the bounding box with topleft.x optionally replaced and size.x optionally replaced.

#   def with_bounds_y( self, new_topleft_y: Union[int, NoneType] = None, new_size_y: Union[int, NoneType] = None ) -> webknossos.geometry.bounding_box.BoundingBox:

Returns a copy of the bounding box with topleft.y optionally replaced and size.y optionally replaced.

#   def with_bounds_z( self, new_topleft_z: Union[int, NoneType] = None, new_size_z: Union[int, NoneType] = None ) -> webknossos.geometry.bounding_box.BoundingBox:

Returns a copy of the bounding box with topleft.z optionally replaced and size.z optionally replaced.

#  
@staticmethod
def from_wkw_dict(bbox: Dict) -> webknossos.geometry.bounding_box.BoundingBox:
#  
@staticmethod
def from_config_dict(bbox: Dict) -> webknossos.geometry.bounding_box.BoundingBox:
#  
@staticmethod
def from_tuple6( tuple6: Tuple[int, int, int, int, int, int] ) -> webknossos.geometry.bounding_box.BoundingBox:
#  
@staticmethod
def from_tuple2( tuple2: Tuple[Union[webknossos.geometry.vec3_int.Vec3Int, Tuple[int, int, int], numpy.ndarray, Iterable[int]], Union[webknossos.geometry.vec3_int.Vec3Int, Tuple[int, int, int], numpy.ndarray, Iterable[int]]] ) -> webknossos.geometry.bounding_box.BoundingBox:
#  
@staticmethod
def from_points( points: Iterable[Union[webknossos.geometry.vec3_int.Vec3Int, Tuple[int, int, int], numpy.ndarray, Iterable[int]]] ) -> webknossos.geometry.bounding_box.BoundingBox:

Returns a bounding box exactly containing all points.

#  
@staticmethod
def from_checkpoint_name(checkpoint_name: str) -> webknossos.geometry.bounding_box.BoundingBox:

This function extracts a bounding box in the format x_y_z_sx_sy_xz which is contained in a string.

#  
@staticmethod
def from_csv(csv_bbox: str) -> webknossos.geometry.bounding_box.BoundingBox:
#  
@staticmethod
def from_auto( obj: Union[webknossos.geometry.bounding_box.BoundingBox, str, Dict, List, Tuple] ) -> webknossos.geometry.bounding_box.BoundingBox:
#  
@staticmethod
def group_boxes_with_aligned_mag( bounding_boxes: collections.abc.Iterable[webknossos.geometry.bounding_box.BoundingBox], aligning_mag: webknossos.geometry.mag.Mag ) -> dict[webknossos.geometry.bounding_box.BoundingBox, list[webknossos.geometry.bounding_box.BoundingBox]]:

Groups the given BoundingBox instances by aligning each bbox to the given mag and using that as the key. For example, bounding boxes of size 2563 could be grouped into the corresponding 10243 chunks to which they belong by using aligning_mag = Mag(1024).

#   def to_wkw_dict(self) -> dict:
#   def to_config_dict(self) -> dict:
#   def to_checkpoint_name(self) -> str:
#   def to_tuple6(self) -> Tuple[int, int, int, int, int, int]:
#   def to_csv(self) -> str:
#   def padded_with_margins( self, margins_left: Union[webknossos.geometry.vec3_int.Vec3Int, Tuple[int, int, int], numpy.ndarray, Iterable[int]], margins_right: Union[webknossos.geometry.vec3_int.Vec3Int, Tuple[int, int, int], numpy.ndarray, Iterable[int], NoneType] = None ) -> webknossos.geometry.bounding_box.BoundingBox:
#   def intersected_with( self, other: webknossos.geometry.bounding_box.BoundingBox, dont_assert: bool = False ) -> webknossos.geometry.bounding_box.BoundingBox:

If dont_assert is set to False, this method may return empty bounding boxes (size == (0, 0, 0))

#   def is_empty(self) -> bool:

Rounds the bounding box, so that both topleft and bottomright are divisible by mag.

:argument ceil: If true, the bounding box is enlarged when necessary. If false, it's shrinked when necessary.

#   def contains( self, coord: Union[webknossos.geometry.vec3_int.Vec3Int, Tuple[int, int, int], numpy.ndarray, Iterable[int]] ) -> bool:

Check whether a point is inside of the bounding box. Note that the point may have float coordinates in the ndarray case

#   def contains_bbox( self, inner_bbox: webknossos.geometry.bounding_box.BoundingBox ) -> bool:
#   def chunk( self, chunk_size: Union[webknossos.geometry.vec3_int.Vec3Int, Tuple[int, int, int], numpy.ndarray, Iterable[int]], chunk_border_alignments: Union[webknossos.geometry.vec3_int.Vec3Int, Tuple[int, int, int], numpy.ndarray, Iterable[int], NoneType] = None ) -> collections.abc.Generator[webknossos.geometry.bounding_box.BoundingBox, NoneType, NoneType]:

Decompose the bounding box into smaller chunks of size chunk_size.

Chunks at the border of the bounding box might be smaller than chunk_size. If chunk_border_alignment is set, all border coordinates between two chunks will be divisible by that value.

#   def volume(self) -> int:
#   def slice_array(self, array: numpy.ndarray) -> numpy.ndarray:
#   def to_slices(self) -> Tuple[slice, slice, slice]:
#   def offset( self, vector: Union[webknossos.geometry.vec3_int.Vec3Int, Tuple[int, int, int], numpy.ndarray, Iterable[int]] ) -> webknossos.geometry.bounding_box.BoundingBox:
Back to top