def preprocess_for_train(image, output_height, output_width, padding=_PADDING):
 tf.image_summary('image', tf.expand_dims(image, 0))
 image = tf.to_float(image)
 if (padding > 0):
  image = tf.pad(image, [[padding, padding], [padding, padding], [0, 0]])
 distorted_image = tf.random_crop(image, [output_height, output_width, 3])
 distorted_image = tf.image.random_flip_left_right(distorted_image)
 tf.image_summary('distorted_image', tf.expand_dims(distorted_image, 0))
 distorted_image = tf.image.random_brightness(distorted_image, max_delta=63)
 distorted_image = tf.image.random_contrast(distorted_image, lower=0.2, upper=1.8)
 return tf.image.per_image_whitening(distorted_image)

def preprocess_for_train ( image , output_height , output_width , padding = _PADDING ) : tf . image_summary ( 'image' , tf . expand_dims ( image , 0 ) ) image = tf . to_float ( image ) if ( padding > 0 ) : image = tf . pad ( image , [ [ padding , padding ] , [ padding , padding ] , [ 0 , 0 ] ] ) distorted_image = tf . random_crop ( image , [ output_height , output_width , 3 ] ) distorted_image = tf . image . random_flip_left_right ( distorted_image ) tf . image_summary ( 'distorted_image' , tf . expand_dims ( distorted_image , 0 ) ) distorted_image = tf . image . random_brightness ( distorted_image , max_delta = 63 ) distorted_image = tf . image . random_contrast ( distorted_image , lower = 0.2 , upper = 1.8 ) return tf . image . per_image_whitening ( distorted_image )
preprocesses the given image for training .