-1
$\begingroup$

If you are training a neural net for a bunch of images of different size, and you have to put them all in a same-size enclosing box for input to the neural net, what's the best way to fill the background, if at all, where the inserted image is not covering the box?

It's basically the flip side of these questions:

$\endgroup$
  • $\begingroup$ The question isn't clear. Could you try to explain it in a clearer fashion? $\endgroup$ – Royi May 26 '18 at 6:25
  • $\begingroup$ @Royi: If you are training a neural net for a bunch of images of different size, and you have to put them all in a same-size enclosing box for input to the neural net, what's the best way to fill the background, if at all, where the inserted image is not covering the box? $\endgroup$ – Lars Ericson May 27 '18 at 1:38
  • $\begingroup$ This is a much clearer explanation. You should rewrite the question in that spirit and I will be able to answer. $\endgroup$ – Royi May 27 '18 at 4:07
  • $\begingroup$ OK thanks the question is rephrased. $\endgroup$ – Lars Ericson May 28 '18 at 4:35
0
$\begingroup$

I think I found the appropriate answer in this patch of code from Google Tensorflow for Poets 2. It does what I needed to do at the moment it needed to get done. The variables input_height and input_width are the destination sizes, not the source sizes:

  float_caster = tf.cast(image_reader, tf.float32)
  dims_expander = tf.expand_dims(float_caster, 0)
  resized = tf.image.resize_bilinear(dims_expander, [input_height, input_width])
  normalized = tf.divide(tf.subtract(resized, [input_mean]), [input_std])
$\endgroup$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.