[Numpy-discussion] 2D Hamming window
Sun Jul 27 04:10:37 CDT 2008
Gary Ruben wrote:
> import numpy as np
> import scipy.signal as ss
> # read heightmap here - in my case it's a square numpy float array
> # build 2d window
> hm_len = heightmap.shape
> bw2d = np.outer(ss.hamming(hm_len), np.ones(hm_len))
> bw2d = np.sqrt(bw2d * bw2d.T) # I don't know whether the sqrt is correct
> # window the heightmap
> heightmap *= bw2d
> Gary R.
Thanks very much for your solution, this is exactly what I needed!
If I'm not mistaken, though, you can achieve the same result with
h = hamming(n)
ham2d = sqrt(outer(h,h))
which is a bit more compact.
More information about the Numpy-discussion