Lescurel
Lescurel

Reputation: 11651

tf.image.pad_to_bounding_box VS tf.pad and tf.image.crop_to_bounding_box VS tf.slice

I'd like to understand why does the two functions tf.image.crop_to_bounding_box and tf.image.pad_to_bounding_box exists, since the behaviour of these two functions can be done really simply with respectively tf.slice and tf.pad.

They are not so much easier to understand, and their scope is narrow since they accept only 3D and 4D tensors. Furthermore, they tend to be slower in terms of time of execution.

Is there something I miss here ?

Upvotes: 1

Views: 1000

Answers (1)

fabmilo
fabmilo

Reputation: 48330

Mostly you use them tf.image.* for easiness of use.

Both crop_to_bounding_box and pad_to_bounding_box use slice and padunderneath, but also add checkings and constraints to make sure you don't spend hours trying to debug your slice/pad indices and offsets.

Upvotes: 3

Related Questions