@Namespace(value="tensorflow::ops") @NoOffset @Properties(inherit=tensorflow.class) public class SampleDistortedBoundingBoxV2 extends Pointer
image_size
,
bounding_boxes
and a series of constraints.
The output of this Op is a single bounding box that may be used to crop the
original image. The output is returned as 3 tensors: begin
, size
and
bboxes
. The first 2 tensors can be fed directly into tf.slice
to crop the
image. The latter may be supplied to tf.image.draw_bounding_boxes
to visualize
what the bounding box looks like.
Bounding boxes are supplied and returned 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,
python
# Generate a single distorted bounding box.
begin, size, bbox_for_draw = tf.image.sample_distorted_bounding_box(
tf.shape(image),
bounding_boxes=bounding_boxes)
# Draw the bounding box in an image summary.
image_with_box = tf.image.draw_bounding_boxes(tf.expand_dims(image, 0),
bbox_for_draw)
tf.summary.image('images_with_box', image_with_box)
# Employ the bounding box to distort the image.
distorted_image = tf.slice(image, begin, size)
Note that if no bounding box information is available, setting
use_image_if_no_bounding_boxes = true
will assume there is a single implicit
bounding box covering the whole image. If use_image_if_no_bounding_boxes
is
false and no bounding boxes are supplied, an error is raised.
Arguments:
* scope: A Scope object
* image_size: 1-D, containing [height, width, channels]
.
* bounding_boxes: 3-D with shape [batch, N, 4]
describing the N bounding boxes
associated with the image.
* min_object_covered: The cropped area of the image must contain at least this
fraction of any bounding box supplied. The value of this parameter should be
non-negative. In the case of 0, the cropped area does not need to overlap
any of the bounding boxes supplied.
Optional attributes (see Attrs
):
* seed: If either seed
or seed2
are set to non-zero, the random number
generator is seeded by the given seed
. Otherwise, it is seeded by a random
seed.
* seed2: A second seed to avoid seed collision.
* aspect_ratio_range: The cropped area of the image must have an aspect ratio =
width / height within this range.
* area_range: The cropped area of the image must contain a fraction of the
supplied image within this range.
* max_attempts: Number of attempts at generating a cropped region of the image
of the specified constraints. After max_attempts
failures, return the entire
image.
* use_image_if_no_bounding_boxes: Controls behavior if no bounding boxes supplied.
If true, assume an implicit bounding box covering the whole input. If false,
raise an error.
Returns:
* Output
begin: 1-D, containing [offset_height, offset_width, 0]
. Provide as input to
tf.slice
.
* Output
size: 1-D, containing [target_height, target_width, -1]
. Provide as input to
tf.slice
.
* Output
bboxes: 3-D with shape [1, 1, 4]
containing the distorted bounding box.
Provide as input to tf.image.draw_bounding_boxes
.Modifier and Type | Class and Description |
---|---|
static class |
SampleDistortedBoundingBoxV2.Attrs
Optional attribute setters for SampleDistortedBoundingBoxV2
|
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter
Constructor and Description |
---|
SampleDistortedBoundingBoxV2(Pointer p)
Pointer cast constructor.
|
SampleDistortedBoundingBoxV2(Scope scope,
Input image_size,
Input bounding_boxes,
Input min_object_covered) |
SampleDistortedBoundingBoxV2(Scope scope,
Input image_size,
Input bounding_boxes,
Input min_object_covered,
SampleDistortedBoundingBoxV2.Attrs attrs) |
address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, getDirectBufferAddress, getPointer, getPointer, getPointer, getPointer, hashCode, interruptDeallocatorThread, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetAddress, offsetof, offsetof, parseBytes, physicalBytes, physicalBytesInaccurate, position, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, sizeof, toString, totalBytes, totalCount, totalPhysicalBytes, withDeallocator, zero
public SampleDistortedBoundingBoxV2(Pointer p)
Pointer(Pointer)
.public SampleDistortedBoundingBoxV2(@Const @ByRef Scope scope, @ByVal Input image_size, @ByVal Input bounding_boxes, @ByVal Input min_object_covered)
@ByVal public static SampleDistortedBoundingBoxV2.Attrs Seed(@Cast(value="tensorflow::int64") long x)
@ByVal public static SampleDistortedBoundingBoxV2.Attrs Seed2(@Cast(value="tensorflow::int64") long x)
@ByVal public static SampleDistortedBoundingBoxV2.Attrs AspectRatioRange(@tensorflow.ArraySlice FloatPointer x)
@ByVal public static SampleDistortedBoundingBoxV2.Attrs AspectRatioRange(@tensorflow.ArraySlice FloatBuffer x)
@ByVal public static SampleDistortedBoundingBoxV2.Attrs AspectRatioRange(@tensorflow.ArraySlice float... x)
@ByVal public static SampleDistortedBoundingBoxV2.Attrs AreaRange(@tensorflow.ArraySlice FloatPointer x)
@ByVal public static SampleDistortedBoundingBoxV2.Attrs AreaRange(@tensorflow.ArraySlice FloatBuffer x)
@ByVal public static SampleDistortedBoundingBoxV2.Attrs AreaRange(@tensorflow.ArraySlice float... x)
@ByVal public static SampleDistortedBoundingBoxV2.Attrs MaxAttempts(@Cast(value="tensorflow::int64") long x)
@ByVal public static SampleDistortedBoundingBoxV2.Attrs UseImageIfNoBoundingBoxes(@Cast(value="bool") boolean x)
public SampleDistortedBoundingBoxV2 operation(Operation setter)
public SampleDistortedBoundingBoxV2 begin(Output setter)
public SampleDistortedBoundingBoxV2 size(Output setter)
public SampleDistortedBoundingBoxV2 bboxes(Output setter)
Copyright © 2022. All rights reserved.