contours.py 文件源码

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

项目:CElegansBehaviour 作者: ChristophKirst 项目源码 文件源码
def detect_contour(img, level):
  """Returns list of vertices of contours at different levels

  Arguments:
    img (array): the image array
    level (number): the level at which to create the contour

  Returns:
    (list of nx2 arrays): list of list of vertices of the different contours

  Note:
    The contour detection is based on matplotlib's QuadContourGenerator
  """
  #parameter
  mask = None;
  corner_mask = True;
  nchunk = 0;

  #prepare image data
  z = ma.asarray(img, dtype=np.float64); 
  ny, nx = z.shape;
  x, y = np.meshgrid(np.arange(nx), np.arange(ny));

  #find contour
  contour_generator = _contour.QuadContourGenerator(x, y, z.filled(), mask, corner_mask, nchunk)
  vertices = contour_generator.create_contour(level);

  return vertices;
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号