简洁之美- 图像处理中的Python(一)


1. scipy中致力于图像处理的子模块- scipy, ndimage

    使用方法: from scipy import ndimage

2. 生成一个gaussian_kernel

# Fill Gaussian kernel                              
      for i in range(gaussian_kernel_width):              
          for j in range(gaussian_kernel_width):          
              gaussian_kernel[i,j]=\
              (1/(2*pi*(gaussian_kernel_sigma**2)))*\     
              exp(-(((i-5)**2)+((j-5)**2))/(2*(gaussian_kernel_sigma**2)))
或者可以:

def func(i, j):
     return (1/(2*pi*(1.5**2)))*exp(-(((i-5)**2)+((j-5)**2))/(2*(1.5**2)))
gaussian_kernel = np.fromfunction(func, (11,11))





你可能感兴趣的:(简洁之美- 图像处理中的Python(一))