fiber_utils.py 文件源码

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

项目:Panacea 作者: grzeimann 项目源码 文件源码
def get_norm_nonparametric_fast(image, Fibers, cols=None, mask=None,
                                plaw_coeff1=0.0004):
    plaw_coeff = np.array([plaw_coeff1, 0.5, 0.15, 1.0])

    bins=len(Fibers[0].binx)
    a,b = image.shape
    if mask is None:
        mask = np.zeros(image.shape)
    ygrid,xgrid = np.indices(image.shape)
    fun = np.zeros((bins,))
    y=ygrid[:,0]
    Fl = np.zeros((len(y), bins))
    P = build_powerlaw(ygrid, Fibers, plaw_coeff, cols)
    init_model = np.zeros((len(y),len(Fibers)))
    if cols is None:
        cols = np.arange(b)
    norm = np.zeros((len(Fibers),b))
    for col in cols:
        for i,fiber in enumerate(Fibers):
            ix = y-fiber.trace[col]
            for j in xrange(bins):
                fun[j] = 1.0
                Fl[:,j] = np.interp(ix,fiber.binx,fun,left=0.0,right=0.0)
                fun[j] = 0.0
            init_model[:,i] = np.dot(Fl, fiber.fibmodel[col,:])+P[:,col,i]
        norm[:,col] = lstsq(init_model[mask[:,col]==0,:], 
                            image[mask[:,col]==0,col])[0]
    return norm
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号