14

I would like to know how to perform image whitening on a batch of images.

According to the documentation in https://www.tensorflow.org/api_docs/python/tf/image/per_image_standardization, it is said that tf.image.per_image_standardization takes as input a 3D tensor, that is an image, of shape: [height, width, channels].

Is it a missing feature or there is a different method?

Any help is much appreciated.

I. A
  • 2,252
  • 26
  • 65

1 Answers1

18

This is how to perform this operation on a batch of images.

tf.map_fn(lambda frame: tf.image.per_image_standardization(frame), frames)

I. A
  • 2,252
  • 26
  • 65
  • 1
    Can you explain your solution? What does the function return? What is `lambda`, `frame` and `frames`? – Gilfoyle Dec 03 '18 at 09:56
  • 1
    `tf.image.per_image_standardization` takes takes as input 1 image at a time. `tf.map_fn` is used to apply a function on every instance of a batch. The batch here is `frames` and each instance of that is a `frame`. As for the lambda, this is pythonic way to create a callable method; which the `tf.map_fn` requires as input. Hope this help – I. A Feb 06 '19 at 21:56
  • 1
    You can now give the function directly a batch of images in tf 1.14 before it was working only on single images. – 183.amir Jul 31 '19 at 16:15