2d convolution using python and numpy
Posted
by mikip
on Stack Overflow
See other posts from Stack Overflow
or by mikip
Published on 2010-03-15T14:56:43Z
Indexed on
2010/03/15
14:59 UTC
Read the original article
Hit count: 194
Hi
I am trying to perform a 2d convolution in python using numpy
I have a 2d array as follows with kernel H_r for the rows and H_c for the columns
data = np.zeros((nr, nc), dtype=np.float32)
#fill array with some data here then convolve
for r in range(nr):
data[r,:] = np.convolve(data[r,:], H_r, 'same')
for c in range(nc):
data[:,c] = np.convolve(data[:,c], H_c, 'same')
It does not produce the output that I was expecting, does this code look OK
Thanks
© Stack Overflow or respective owner