(image, central_fraction)
return image
Crop the central region of the image.

  Remove the outer parts of an image but retain the central region of the image
  along each dimension. If we specify central_fraction = 0.5, this function
  returns the region marked with "X" in the below diagram.

       --------
      |        |
      |  XXXX  |
      |  XXXX  |
      |        |   where "X" is the central 50% of the image.
       --------

  Args:
    image: 3-D float Tensor of shape [height, width, depth]
    central_fraction: float (0, 1], fraction of size to crop

  Raises:
    ValueError: if central_crop_fraction is not within (0, 1].

  Returns:
    3-D float Tensor
Crop the central region of the image.
Crop the central region of the image .
def central_crop(image, central_fraction):
  """Crop the central region of the image.

  Remove the outer parts of an image but retain the central region of the image
  along each dimension. If we specify central_fraction = 0.5, this function
  returns the region marked with "X" in the below diagram.

       --------
      |        |
      |  XXXX  |
      |  XXXX  |
      |        |   where "X" is the central 50% of the image.
       --------

  Args:
    image: 3-D float Tensor of shape [height, width, depth]
    central_fraction: float (0, 1], fraction of size to crop

  Raises:
    ValueError: if central_crop_fraction is not within (0, 1].

  Returns:
    3-D float Tensor
  """
  image = ops.convert_to_tensor(image, name='image')
  if central_fraction <= 0.0 or central_fraction > 1.0:
    raise ValueError('central_fraction must be within (0, 1]')
  if central_fraction == 1.0:
    return image

  image = control_flow_ops.with_dependencies(
      _Check3DImage(image, require_static=False), image)

  img_shape = array_ops.shape(image)
  depth = image.get_shape()[2]
  img_h = math_ops.to_double(img_shape[0])
  img_w = math_ops.to_double(img_shape[1])
  bbox_h_start = math_ops.to_int32((img_h - img_h * central_fraction) / 2)
  bbox_w_start = math_ops.to_int32((img_w - img_w * central_fraction) / 2)

  bbox_h_size = img_shape[0] - bbox_h_start * 2
  bbox_w_size = img_shape[1] - bbox_w_start * 2

  bbox_begin = array_ops.stack([bbox_h_start, bbox_w_start, 0])
  bbox_size = array_ops.stack([bbox_h_size, bbox_w_size, -1])
  image = array_ops.slice(image, bbox_begin, bbox_size)

  # The first two dimensions are dynamic and unknown.
  image.set_shape([None, None, depth])
  return image
def central_crop ( image , central_fraction ) : image = ops . convert_to_tensor ( image , name = 'image' ) if central_fraction <= 0.0 or central_fraction > 1.0 : raise ValueError ( 'central_fraction must be within (0, 1]' ) if central_fraction == 1.0 : return image image = control_flow_ops . with_dependencies ( _Check3DImage ( image , require_static = False ) , image ) img_shape = array_ops . shape ( image ) depth = image . get_shape ( ) [ 2 ] img_h = math_ops . to_double ( img_shape [ 0 ] ) img_w = math_ops . to_double ( img_shape [ 1 ] ) bbox_h_start = math_ops . to_int32 ( ( img_h - img_h * central_fraction ) / 2 ) bbox_w_start = math_ops . to_int32 ( ( img_w - img_w * central_fraction ) / 2 ) bbox_h_size = img_shape [ 0 ] - bbox_h_start * 2 bbox_w_size = img_shape [ 1 ] - bbox_w_start * 2 bbox_begin = array_ops . stack ( [ bbox_h_start , bbox_w_start , 0 ] ) bbox_size = array_ops . stack ( [ bbox_h_size , bbox_w_size , - 1 ] ) image = array_ops . slice ( image , bbox_begin , bbox_size ) # The first two dimensions are dynamic and unknown. image . set_shape ( [ None , None , depth ] ) return image