I have the following code. I'm reading a greyscale image into f and simply need to treat it as a function f(x,y) and transform it into g(x,y)=f(-x,y) and g(x,y)=f(kx,ky). In general, I need to be able to transform the image as g(x,y)=f(ax,bx). It should be very straightforward, but I have tried various approaches (all ultimately wrong so not shown) but can't properly access the pixel values to multiply them - there is always some kind of error I can't solve.
My question is: how do I transform f in the mathematical way shown (commented as #####... in the code) correctly?
Note: f becomes a 3D numpy array when "filename" is read.
Thank you for any assistance.
import matplotlib.pyplot as plt
import numpy as np
rows = 2
cols = 2
axes=[]
fig=plt.figure()
f = np.array(plt.imread(r"filename", format = None)
b = 3
g1 = b*f
##### g2 = f(-x,y)
##### g3 = f(k*x,k*y)
masterfx =[f, g1, g2, g3]
for i in range(rows*cols):
axes.append( fig.add_subplot(rows, cols, i+1) )
subplot_title=("Image "+str(i+1))
axes[-1].set_title(subplot_title)
plt.imshow(masterfx[i])
fig.tight_layout()
plt.show()