I have a batches of images represented as TensorFlow tensor (say Tensor 1) of shape (2,1024,1024,1) of the form (B,H,W,C) where B is the batch size 2, H and W are image dimensions 1024 and C is the number of channels. Each element of this tensor (i.e. each pixel) stores a tuple (a,b) where both a and b are in the range 0 and 255.
I have another tensor (say Tensor 2) of shape (256,256) for which each element stores a single value between 0 and 255.
Given this setup, I have the following question.
I wish to replace each element value in Tensor 1 with the corresponding element value in Tensor 2. For example, let's assume that the element given by index (1,200,500,1) in tensor 1 contains the value (100,20). I want to look up the value stored in Tensor 2 at pixel location (100,200) and modify the entry at (1,200,500,1) with this value.
How can I do this in the most efficient way possible for the entire batch?
Please let me know if something is unclear. I am a beginner to TensorFlow, hence would appreciate any help.