Could you tell me if there is any 'smart' way to generate a 3D numpy array based on provided pattern? Let me explain what I mean by this. E.g., if pattern is [1, 4, 6, 4, 1], corresponding 2D array for it would be:
[
[1, 1, 1, 1, 1],
[1, 4, 4, 4, 1],
[1, 4, 6, 4, 1],
[1, 4, 4, 4, 1],
[1, 1, 1, 1, 1]
]
And 3D array is similar to 2D. If you imagine that 3D array as a cube: just one 6 in the center of 'cube', twenty six 4s around it in the closest neighborhood, and the rest 1s.
I apologize for potentially confusing explanation, I'm not a native English speaker. Please ask if something is unclear.
Thanks!
Any python library can be used.
numpyindexing is powerful and a pattern is just defined using math that python can do, so implementing it yourself is not a large task if you don't need to handle an arbitrary number of dimensions.