[SciPy-User] Avoiding lambda functions
Mon Oct 18 19:08:46 CDT 2010
> Reply to all.
Many thanks to Robert and Zachary. I see now we don't even need the
gaussianfilter function. We can just use gauss directly. Code modifications
Thanks also to Stefan. I'll check out py4science.
> from numpy import exp, indices # numpy package from scipy.org
> img0 = imread('Lena.pgm') # a 200 by 200 greyscale image
> shape = img0.shape # (200, 200)
> def gauss(i,j,sigma,shape): # a 2D gaussian function
> x = -1.0 + 2.0*i/shape
> y = -1.0 + 2.0*j/shape
> return exp(-(x*x+y*y)/(2*sigma*sigma))
iray, jray = indices(shape)
filter = gauss(iray, jray, 0.1, shape)
More information about the SciPy-User