def resize_and_crop_image(image, label): # Resize and crop using "fill" algorithm: # always make sure the resulting image # is cut out from the source image so that # it fills the TARGET_SIZE entirely with no # black bars and a preserved aspect ratio. w = tf.shape(image) h = tf.shape(image) tw = TARGET_SIZE th = TARGET_SIZE resize_crit = (w * th) / (h * tw) image = tf.cond(resize_crit < 1, lambda: tf.image.resize(image, [w*tw/w, h*tw/w]), # if true lambda: tf.image.resize(image, [w*th/h, h*th/h]) # if false ) nw = tf.shape(image) nh = tf.shape(image) image = tf.image.crop_to_bounding_box(image, (nw - tw) // 2, (nh - th) // 2, tw, th) return image, label
I have gone through google search results and didn't find any such algorithm for image resizing and cropping. Please help me understand
- What is this algorithm doing?
- What is the role of the equation used in