def _butterworth_filter(rows, cols, thresh, order):
# X and Y matrices with ranges normalised to +/- 0.5
array1 = np.ones(rows)
array2 = np.ones(cols)
array3 = np.arange(1,rows+1)
array4 = np.arange(1,cols+1)
x = np.outer(array1, array4)
y = np.outer(array3, array2)
x = x - float(cols/2) - 1
y = y - float(rows/2) - 1
x = x / cols
y = y / rows
radius = np.sqrt(np.square(x) + np.square(y))
matrix1 = radius/thresh
matrix2 = np.power(matrix1, 2*order)
f = np.reciprocal(1 + matrix2)
return f
评论列表
文章目录