def _crop(image, offset_height, offset_width, crop_height, crop_width):
 original_shape = tf.shape(image)
 rank_assertion = tf.Assert(tf.equal(tf.rank(image), 3), ['Rank of image must be equal to 3.'])
 cropped_shape = control_flow_ops.with_dependencies([rank_assertion], tf.pack([crop_height, crop_width, original_shape[2]]))
 size_assertion = tf.Assert(tf.logical_and(tf.greater_equal(original_shape[0], crop_height), tf.greater_equal(original_shape[1], crop_width)), ['Crop size greater than the image size.'])
 offsets = tf.to_int32(tf.pack([offset_height, offset_width, 0]))
 image = control_flow_ops.with_dependencies([size_assertion], tf.slice(image, offsets, cropped_shape))
 return tf.reshape(image, cropped_shape)

def _crop ( image , offset_height , offset_width , crop_height , crop_width ) : original_shape = tf . shape ( image ) rank_assertion = tf . Assert ( tf . equal ( tf . rank ( image ) , 3 ) , [ 'Rank of image must be equal to 3.' ] ) cropped_shape = control_flow_ops . with_dependencies ( [ rank_assertion ] , tf . pack ( [ crop_height , crop_width , original_shape [ 2 ] ] ) ) size_assertion = tf . Assert ( tf . logical_and ( tf . greater_equal ( original_shape [ 0 ] , crop_height ) , tf . greater_equal ( original_shape [ 1 ] , crop_width ) ) , [ 'Crop size greater than the image size.' ] ) offsets = tf . to_int32 ( tf . pack ( [ offset_height , offset_width , 0 ] ) ) image = control_flow_ops . with_dependencies ( [ size_assertion ] , tf . slice ( image , offsets , cropped_shape ) ) return tf . reshape ( image , cropped_shape )
crops the given image using the provided offsets and sizes .