common.py 文件源码

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

项目:nimo 作者: wolfram2012 项目源码 文件源码
def _resizeFilter(self,size):
        '''
        Resize the filter 
        '''
        if size == self.filter.shape:
            return self.filter

        if not self.filter_cache.has_key(size):
            filter = np.fft.ifft2(self.filter)
            w,h = size

            fw,fh = filter.shape
            tmp = np.zeros((w,h), np.complex128) #TODO: check this

            w = min(w,fw)
            h = min(h,fh)

            tmp[ :w/2, :h/2] = filter[ :w/2, :h/2]
            tmp[ :w/2,-h/2:] = filter[ :w/2,-h/2:]
            tmp[-w/2:,-h/2:] = filter[-w/2:,-h/2:]
            tmp[-w/2:, :h/2] = filter[-w/2:, :h/2]

            self.filter_cache[size] = np.fft.fft2(tmp)

        return self.filter_cache[size]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号