orientation_filter.py 文件源码

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

项目:image_analysis 作者: CoDaS-Lab 项目源码 文件源码
def noise_amp(self, size):
        """
        DESCRIPTION:
            Creates a size x size matrix of randomly generated noise with
            amplitude values with 1/f slope

        ARGS:
            :size: size of matrix

        RETURNS:
            :returns the amplitudes with noise added
        """

        slope = 1
        x = y = np.linspace(1, size, size)
        xgrid, ygrid = np.meshgrid(x, y)  # coordinates for a square grid
        xgrid = np.subtract(xgrid, size // 2)
        ygrid = np.subtract(ygrid, size // 2)

        amp = self.fft.fftshift(np.divide(np.sqrt(np.square(xgrid) +
                                          np.square(ygrid)),
                                          size * np.sqrt(2)))
        amp = np.rot90(amp, 2)
        amp[0, 0] = 1
        amp = 1 / amp**slope
        amp[0, 0] = 0
        return amp
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号