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
评论列表
文章目录