微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在PythonJupyter中构建用于计算点扩散函数图像处理的函数?

如何解决如何在PythonJupyter中构建用于计算点扩散函数图像处理的函数?

在图像处理中,对图像进行傅立叶变换,然后进行傅立叶中心变换,然后进行欠采样,然后返回到逆中心变换,再通过逆傅立叶变换返回图像。那么,要计算点扩散函数,下面的函数还可以吗?

def apply_Fu(sampling_pattern,x):
    #compute subsampled FFT    #Sampling pattern is matrix where 1 means we take that sample for undersampling

    return sampling_pattern*np.fft.fftshift(np.fft.fft2(x))

def apply_Fu_adjoint(sampling_pattern,y):
    #Compute adjoing of subsampled k space
    return np.fft.ifft2(np.fft.ifftshift(sampling_pattern*y))

def spr(gridsize,sampling_pattern):
    # gridsize should be 2-element tuple,e.g. gridsize = (10,10)
    maxima = np.zeros(gridsizedtype = np.complex_)
    for x in range(gridsize[0]):
        for y in range(gridsize[1]):
            # in this iteration,the index "i" corresponds to the gridpoint (x,y)

            # construct basis vector
            e_i = np.zeros(gridsize,dtype = np.complex_)
            e_i[x,y] = 1

            # compute psf_i = Fu* Fu e_i
            # psf_i[xx,yy] is PSF(i,j) if index "j" corresponds to gridpoint (xx,yy)
            psf_i = apply_Fu_adjoint(sampling_pattern,apply_Fu(sampling_pattern,e_i))

            # normalize; psf_i[x,y] is PSF(i,i)
            psf_i = psf_i / psf_i[x,y]

            # trick to exclude point "i" itself from maximum: set it to -infinity
            psf_i[x,y] = -np.inf

            # "inner" maximum,over "j"
            maxima[x,y] = np.max(psf_i)
    spr = np.max(maxima)
    return spr

spr = spr(img.shape,random)

np.abs(spr)```

解决方法

您可以使用此 https://github.com/cgohlke/psf,一个用于荧光显微镜的点扩散函数计算

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。