本文主要是介绍tf.image.draw_bounding_boxes,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
____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 有相同的类型和形状。
官网地址:
源码: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 boundingboxes specified by the locations in `boxes`. The coordinates of the eachbounding box in `boxes` are encoded as `[y_min, x_min, y_max, x_max]`. Thebounding box coordinates are floats in `[0.0, 1.0]` relative to the width andheight 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 thebounding 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 boundingboxes.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 withbounding boxes drawn on the images."""result = _op_def_lib.apply_op("DrawBoundingBoxes", images=images,boxes=boxes, name=name)return result
.
这篇关于tf.image.draw_bounding_boxes的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!