strf.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:spykes 作者: KordingLab 项目源码 文件源码
def make_2d_gaussian(self, center=(0, 0)):
        '''Makes a 2D Gaussian filter with arbitary mean and variance.

        Args:
            center (tuple): The coordinates of the center of the Gaussian,
                specified as :data:`(row, col)`. The center of the image is
                :data:`(0, 0)`.

        Returns:
            numpy array: The Gaussian mask.
        '''
        sigma = self.sigma
        n_rows = (self.patch_size - 1.) / 2.
        n_cols = (self.patch_size - 1.) / 2.

        y, x = np.ogrid[-n_rows: n_rows + 1, -n_cols: n_cols + 1]
        y0, x0 = center[1], center[0]
        gaussian_mask = np.exp(-((x - x0) ** 2 + (y - y0) ** 2) /
                               (2. * sigma ** 2))
        gaussian_mask[gaussian_mask <
                      np.finfo(gaussian_mask.dtype).eps *
                      gaussian_mask.max()] = 0
        gaussian_mask = 1. / gaussian_mask.max() * gaussian_mask
        return gaussian_mask
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号