psf_tools.py 文件源码

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

项目:Optics 作者: danustc 项目源码 文件源码
def psf_zplane(stack, dz, w0, de = 1):
    '''
    determine the position of the real focal plane.
    Don't mistake with psf_slice!
    '''
    nz, ny, nx = stack.shape
    cy, cx = np.unravel_index(np.argmax(gf(stack,2)), (nz,ny,nx))[1:]

    zrange = (nz-1)*dz*0.5
    zz = np.linspace(-zrange, zrange, nz)
    center_z = stack[:,cy-de:cy+de+1,cx-de:cx+de+1]
    im_z = center_z.mean(axis=2).mean(axis=1)

    b = np.mean((im_z[0],im_z[-1]))
    a = im_z.max() - b

    p0 = (a,0,w0,b)
    popt = optimize.curve_fit(gaussian, zz, im_z, p0)[0]
    z_offset = popt[1] # The original version is wrong
    return z_offset, zz
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号