Cropping

tomni.json_operations.crop_json(json_list: List[dict], x_translation: int, y_translation: int, crop_dim: Union[list, tuple], crop_mode: str = 'remove_objects') List[dict][source]

Crop a list of JSON objects based on translation and crop dimensions.

Parameters
  • json_list (List[dict]) – A list of JSON objects in standard AxionBio format.

  • x_translation (int) – The translation in the x-direction of the cropped JSON relative to the original JSON.

  • y_translation (int) – The translation in the y-direction of the cropped JSON relative to the original JSON.

  • crop_dim (Union[list, tuple]) – Crop dimensions (x, y) of the cropped JSON.

  • crop_mode (str) – Crop mode, either “remove_objects” (default) or “keep_objects”.

Returns

A list of JSON objects after cropping and translation.

Return type

List[dict]

Note

  • In “remove_objects” mode, JSON objects with centers outside the crop area are removed.

  • In “keep_objects” mode, JSON objects with centers outside the crop area but with parts inside the crop area are kept, and new JSON objects are created with adjusted centers.