Rename sigma parameters by adding an underscore as separator

This commit is contained in:
Johannes Schönberger
2013-04-06 19:21:08 +02:00
parent e30fa821d9
commit 95d1e627c6
+11 -11
View File
@@ -2,7 +2,7 @@ import numpy as np
from scipy import ndimage
def gabor_kernel(sigmax, sigmay, frequency, theta, offset=0):
def gabor_kernel(sigma_x, sigma_y, frequency, theta, offset=0):
"""Build complex 2D Gabor filter kernel.
Frequency and orientation representations of the Gabor filter are similar to
@@ -11,9 +11,9 @@ def gabor_kernel(sigmax, sigmay, frequency, theta, offset=0):
Parameters
----------
sigmax : float
sigma_x : float
Standard deviation in x-direction.
sigmay : float
sigma_y : float
Standard deviation in y-direction.
frequency : float
Frequency of the harmonic function.
@@ -34,22 +34,22 @@ def gabor_kernel(sigmax, sigmay, frequency, theta, offset=0):
"""
x0 = np.ceil(max(3 * sigmax, 1))
y0 = np.ceil(max(3 * sigmay, 1))
x0 = np.ceil(max(3 * sigma_x, 1))
y0 = np.ceil(max(3 * sigma_y, 1))
y, x = np.mgrid[-y0:y0+1, -x0:x0+1]
rotx = x * np.cos(theta) + y * np.sin(theta)
roty = -x * np.sin(theta) + y * np.cos(theta)
g = np.zeros(y.shape, dtype=np.complex)
g[:] = np.exp(-0.5 * (rotx**2 / sigmax**2 + roty**2 / sigmay**2))
g /= 2 * np.pi * sigmax * sigmay
g[:] = np.exp(-0.5 * (rotx**2 / sigma_x**2 + roty**2 / sigma_y**2))
g /= 2 * np.pi * sigma_x * sigma_y
g *= np.exp(1j * (2 * np.pi * frequency * rotx + offset))
return g
def gabor_filter(image, sigmax, sigmay, frequency, theta, offset=0,
def gabor_filter(image, sigma_x, sigma_y, frequency, theta, offset=0,
mode='reflect', cval=0):
"""Perform Gabor filtering.
@@ -62,9 +62,9 @@ def gabor_filter(image, sigmax, sigmay, frequency, theta, offset=0,
Parameters
----------
sigmax : float
sigma_x : float
Standard deviation in x-direction.
sigmay : float
sigma_y : float
Standard deviation in y-direction.
frequency : float
Frequency of the harmonic function.
@@ -86,7 +86,7 @@ def gabor_filter(image, sigmax, sigmay, frequency, theta, offset=0,
"""
g = gabor_kernel(sigmax, sigmay, frequency, theta, offset)
g = gabor_kernel(sigma_x, sigma_y, frequency, theta, offset)
filtered_real = ndimage.convolve(image, np.real(g), mode=mode, cval=cval)
filtered_imag = ndimage.convolve(image, np.imag(g), mode=mode, cval=cval)