tensorflow源码 tf.image.draw_bounding_boxes

来源:互联网 发布:吴京收入知乎 编辑:程序博客网 时间:2024/06/03 07:29

____tz_zs源码学习


在一批图像上绘制边框。

draw_bounding_boxes(    images,    boxes,    name=None)
images:是 [batch, height, width, depth] 形状的四维矩阵,数据类型为 float32、half 中的一种,第一个值batch是因为处理的是一组图片。

boxes: 形状 [batch, num_bounding_boxes, 4] 的三维矩阵, num_bounding_boxes 是标注框的数量,标注框由四个数字标示 [y_min, x_min, y_max, x_max],数组类型为float32。例如:tf.constant([[[0.05, 0.05, 0.9, 0.7], [0.35, 0.47, 0.5, 0.56]]]) shape 为 [1,2,4] 表示一张图片中的两个标注框;tf.constant([[[ 0.  0.  1.  1.]]]) 的 shape 为 [1,1,4]表示一张图片中的一个标注框

name:操作的名称(可选)。


return: 返回加入了标注框的图像,与输入的 images 有相同的类型和形状。




官网地址: https://www.tensorflow.org/api_docs/python/tf/image/draw_bounding_boxes

源码:

tensorflow/python/ops/gen_image_ops.py

def draw_bounding_boxes(images, boxes, name=None):  r"""Draw bounding boxes on a batch of images.  Outputs a copy of `images` but draws on top of the pixels zero or more bounding  boxes specified by the locations in `boxes`. The coordinates of the each  bounding box in `boxes` are encoded as `[y_min, x_min, y_max, x_max]`. The  bounding box coordinates are floats in `[0.0, 1.0]` relative to the width and  height of the underlying image.  For example, if an image is 100 x 200 pixels and the bounding box is  `[0.1, 0.2, 0.5, 0.9]`, the bottom-left and upper-right coordinates of the  bounding box will be `(10, 40)` to `(50, 180)`.  Parts of the bounding box may fall outside the image.  Args:    images: A `Tensor`. Must be one of the following types: `float32`, `half`.      4-D with shape `[batch, height, width, depth]`. A batch of images.    boxes: A `Tensor` of type `float32`.      3-D with shape `[batch, num_bounding_boxes, 4]` containing bounding      boxes.    name: A name for the operation (optional).  Returns:    A `Tensor`. Has the same type as `images`.    4-D with the same shape as `images`. The batch of input images with    bounding boxes drawn on the images.  """  result = _op_def_lib.apply_op("DrawBoundingBoxes", images=images,                                boxes=boxes, name=name)  return result