How to perform tf.image.per_image_standardization on a batch of images in tensorflow
Asked Answered
R

1

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.

Rosiarosicrucian answered 13/6, 2017 at 16:17 Comment(2)
usually, Tf pipelines involves preprocessing on single image and queuing them to generate batches. For example: github.com/tensorflow/models/blob/master/inception/inception/…Monatomic
@HarshaPokkalla, link rot!Dorset
R
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)

Rosiarosicrucian answered 13/6, 2017 at 18:5 Comment(3)
Can you explain your solution? What does the function return? What is lambda, frame and frames?Earplug
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 helpRosiarosicrucian
You can now give the function directly a batch of images in tf 1.14 before it was working only on single images.Fuliginous

© 2022 - 2024 — McMap. All rights reserved.