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.

2

1 Answer 1

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)

3
  • 1
    Can you explain your solution? What does the function return? What is lambda, frame and frames?
    – Gilfoyle
    Commented Dec 3, 2018 at 9: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
    Commented Feb 6, 2019 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
    Commented Jul 31, 2019 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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