model_old.py 文件源码

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

项目:CElegansBehaviour 作者: ChristophKirst 项目源码 文件源码
def error_center_line(self, image, npoints = all, order = 1, overlap = True):
    """Error between worm center line and image

    Arguments:
      image (array): gray scale image of worm
    """
    import shapely.geometry as geo

    if overlap:
      xyl, xyr, cl = self.sides(npoints = npoints);
      w = np.ones(npoints);
      #plt.figure(141); plt.clf();
      worm = geo.Polygon();
      for i in range(npoints-1):
        poly = geo.Polygon(np.array([xyl[i,:], xyr[i,:], xyr[i+1,:], xyl[i+1,:]]));
        ovl = worm.intersection(poly).area;
        tot = poly.area;
        w[i+1] = 1 - ovl / tot;
        worm = worm.union(poly);

      #print w
      return np.sum(w * nd.map_coordinates(image.T, cl.T, order = order))
    else:
      cl = self.center_line(npoints = npoints);
      return np.sum(nd.map_coordinates(image.T, cl.T, order = order))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号