Hello,
I have a batch of images: (num, height, width, channels)
I also have a spatial transformation matrix: (2, 3)
This is meant to be applied pixel-wise across each channel, for each sample.
For example, applying this transformation to pixel (80, 90) of the first channel of the first image in the batch:
inputImgs = tf.Variable(np.zeros((batch_size, height, width, 3)))
outputImgs = tf.Variable(np.zeros((batch_size, height, width, 3)))
// Apply transformation to point (80, 90) of channel 0 of image 0
trans = [[-1, 0, -0.5 * width], [0, 1, -0.5 * height]] // size (2, 3)
loc = [[80], [90], [1]] // add row with 1 to make size (3, 1)
transformed_loc = trans * loc
outputImgs[0, 80, 90, 0] = inputImgs[0, transformed_loc[0], transformed_loc[1], 0]
I'm having difficulty conceptualizing the fastest way to perform this transformation to a single image, let alone the entire batch of images.
In effect, I want to add another dimension to the input multiply every pixel by a transformation matrix somehow.
Thanks for your help in advance.