(images, offset_height, offset_width, target_height, target_width)
return images[:, top:bottom, left:right, :]
Crops a batch of images to the given dimensions.

    @param images: 4-D tensor with shape [batch, height, width, channels]
    @param offset_height: Vertical coordinate of the top-left corner of the result in the input.
    @param offset_width: Horizontal coordinate of the top-left corner of the result in the input.
    @param target_height: Height of output images.
    @param target_width: Width of output images.

    @return: The batch of images, all cropped the specified dimensions.
Crops a batch of images to the given dimensions.
Crops a batch of images to the given dimensions .
def batch_crop_to_bounding_box(images, offset_height, offset_width, target_height, target_width):
    """
    Crops a batch of images to the given dimensions.

    @param images: 4-D tensor with shape [batch, height, width, channels]
    @param offset_height: Vertical coordinate of the top-left corner of the result in the input.
    @param offset_width: Horizontal coordinate of the top-left corner of the result in the input.
    @param target_height: Height of output images.
    @param target_width: Width of output images.

    @return: The batch of images, all cropped the specified dimensions.
    """
    batch_size, height, width, channels = tf.Session().run(tf.shape(images))

    if not offset_height >= 0:
        raise ValueError('offset_height must be >= 0')
    if not offset_width >= 0:
        raise ValueError('offset_width must be >= 0')
    if not target_height + offset_height <= height:
        raise ValueError('target_height + offset_height must be <= height')
    if not target_width <= width - offset_width:
        raise ValueError('target_width + offset_width must be <= width')

    top = offset_height
    bottom = target_height + offset_height
    left = offset_width
    right = target_width + offset_width

    return images[:, top:bottom, left:right, :]
def batch_crop_to_bounding_box ( images , offset_height , offset_width , target_height , target_width ) : batch_size , height , width , channels = tf . Session ( ) . run ( tf . shape ( images ) ) if not offset_height >= 0 : raise ValueError ( 'offset_height must be >= 0' ) if not offset_width >= 0 : raise ValueError ( 'offset_width must be >= 0' ) if not target_height + offset_height <= height : raise ValueError ( 'target_height + offset_height must be <= height' ) if not target_width <= width - offset_width : raise ValueError ( 'target_width + offset_width must be <= width' ) top = offset_height bottom = target_height + offset_height left = offset_width right = target_width + offset_width return images [ : , top : bottom , left : right , : ]