postprocess.py 文件源码

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

项目:picasso 作者: jungmannlab 项目源码 文件源码
def undrift(locs, info, segmentation, display=True, segmentation_callback=None, rcc_callback=None):
    bounds, segments = _render.segment(locs, info, segmentation,
                                       {'blur_method': 'gaussian', 'min_blur_width': 1},
                                       segmentation_callback)
    shift_y, shift_x = _imageprocess.rcc(segments, 32, rcc_callback)
    t = (bounds[1:] + bounds[:-1]) / 2
    drift_x_pol = _interpolate.InterpolatedUnivariateSpline(t, shift_x, k=3)
    drift_y_pol = _interpolate.InterpolatedUnivariateSpline(t, shift_y, k=3)
    t_inter = _np.arange(info[0]['Frames'])
    drift = (drift_x_pol(t_inter), drift_y_pol(t_inter))
    drift = _np.rec.array(drift, dtype=[('x', 'f'), ('y', 'f')])
    if display:
        fig1 = _plt.figure(figsize=(17, 6))
        _plt.suptitle('Estimated drift')
        _plt.subplot(1, 2, 1)
        _plt.plot(drift.x, label='x interpolated')
        _plt.plot(drift.y, label='y interpolated')
        t = (bounds[1:] + bounds[:-1]) / 2
        _plt.plot(t, shift_x, 'o', color=list(_plt.rcParams['axes.prop_cycle'])[0]['color'], label='x')
        _plt.plot(t, shift_y, 'o', color=list(_plt.rcParams['axes.prop_cycle'])[1]['color'], label='y')
        _plt.legend(loc='best')
        _plt.xlabel('Frame')
        _plt.ylabel('Drift (pixel)')
        _plt.subplot(1, 2, 2)
        _plt.plot(drift.x, drift.y, color=list(_plt.rcParams['axes.prop_cycle'])[2]['color'])
        _plt.plot(shift_x, shift_y, 'o', color=list(_plt.rcParams['axes.prop_cycle'])[2]['color'])
        _plt.axis('equal')
        _plt.xlabel('x')
        _plt.ylabel('y')
        fig1.show()
    locs.x -= drift.x[locs.frame]
    locs.y -= drift.y[locs.frame]
    return drift, locs
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号