The original image is in shape (720, 1280) and contains a bounding box. I need to make it square without disturbing the spatial information. Please look at the below picture.
I’m not sure how to add such up-down padding to this image to make it a square shape. The width is 1280 and the height is 720. So, to make it square I need to add a border of shape (1280-720) = 560 - divided by 2 - 280 px up and down. How to do this in tensorflow efficiently and dynamically?
if your Image is a tensor with shape (720, 1280,3) ( 3 channels for RGB image) then it should work with paddings = tf.constant([[280, 280], [0, 0], [0,0]])
lets say it is the x-axis where you add two times 280 pixels. then the x-coordinates of your bounding boxes has to be increased by 280 pixels. as the original image is not distorted, you dont have to change the size of the bounding boxes. just their position