I have a 1D array and I want to rotate it around its centre to generate a symmetric 2D array. How can I do it?
For example, I define a 1D window array via scipy and now I want to generate its 2D version which has rotation symmetry. However, the result of numpy.outer doesn't have rotation symmetry.
from scipy.signal import windows
import matplotlib.pyplot as plt
exp1 = windows.get_window(('exponential', None, 5), 60)
exp2d = np.sqrt(np.outer(exp1, exp1))
plt.imshow(exp2d)

I realize that if the 1D window has a analytical form, it is simple to do it. However, is there some general method for an arbitrary 1D array (function) without analytical form?
Yes, this can be done. Here is a possible approach:
Generate a "radius" image like this, where at each point, the pixel value is its distance from the center:

Evaluate f(radius), where f is any 1D function. For instance:

Alternatively, if you have a 1D array and not a function, interpolate it for instance with scipy.interpolate.interp1d like f = interpolate.interp1d(x, y).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With