我该如何在Tensorflow中使用Python API将图像剪裁到边界框?
根据文档,
tf.image.crop_to_bounding_box(image, offset_height, offset_width, target_height, target_width)
将图像裁剪为指定的边界框。
此操作从图像中截取一个矩形部分。返回图像的左上角位于图像中的 offset_height、offset_width,右下角位于 offset_height + target_height、offset_width + target_width。
我可以获取标准化坐标下的边界框坐标,例如:
ymin = boxes[0,i,0]
xmin = boxes[0,i,1]
ymax = boxes[0,i,2]
xmax = boxes[0,i,3]
并将这些转换为绝对坐标,
(xminn, xmaxx, yminn, ymaxx) = (xmin * im_width, xmax * im_width, ymin * im_height, ymax * im_height)
然而我不知道如何在crop_to_bounding_box
函数中使用这些坐标。