View source on GitHub
|
Crops bounding boxes based on the given offsets and dimensions.
tf.keras.utils.bounding_boxes.crop(
boxes, top, left, height, width, bounding_box_format='xyxy'
)
This function crops bounding boxes to a specified region defined by
top, left, height, and width. The boxes are first converted to
xyxy format, cropped, and then returned.
Returns | |
|---|---|
| The cropped bounding boxes. |
Example:
boxes = np.array([[10, 20, 50, 60], [70, 80, 100, 120]]) # xyxy format
cropped_boxes = keras.utils.bounding_boxes.crop(
boxes, bounding_box_format="xyxy", top=10, left=20, height=40, width=30
) # Cropping a 30x40 region starting at (20, 10)
print(cropped_boxes)
# Expected output:
# array([[ 0., 10., 30., 50.],
# [50., 70., 80., 110.]])
View source on GitHub