ยป Keras API reference / KerasCV / Bounding box formats and utilities / Bounding box utilities / Clip bounding boxes to be within the bounds of provided images

Clip bounding boxes to be within the bounds of provided images

[source]

clip_to_image function

keras_cv.bounding_box.clip_to_image(bounding_boxes, images, bounding_box_format)

clips bounding boxes to image boundaries.

clip_to_image() clips bounding boxes that have coordinates out of bounds of an image down to the boundaries of the image. This is done by converting the bounding box to relative formats, then clipping them to the [0, 1] range. Additionally, bounding boxes that end up with a zero area have their class ID set to -1, indicating that there is no object present in them.

Arguments

  • bounding_boxes: bounding box tensor to clip.
  • images: list of images to clip the bounding boxes to.
  • bounding_box_format: the KerasCV bounding box format the bounding boxes are in.