Skip to content
Jason Furtney edited this page Apr 18, 2016 · 6 revisions

Welcome to the scikit-fmm wiki!

Contour lengths

from skimage.measure import find_contours

def contour_length(contour_set):
    """
    Calculate the length of the contours returned by skimage.measure.find_contours
    """
    total_length = 0.0
    for path in contour_set:
        for i in range(len(path)-1):
            p0, p1 = path[i], path[i+1]
            total_length += (np.linalg.norm(p0-p1)).sum()
    return total_length

print contour_length(find_contours(phi, 0.0))

Or using the matplotlib contours.

def contour_length(contour_set):
     """
     Calculate the length of the contours in a matplotlib.contour.ContourSet object.
     ContourSet objects are returned by matplotlib.pyplot.contour()
     """
     total_length = 0.0
     for path in contour_set.collections[0].get_paths():
          path_list = list(path.iter_segments())
          for i in range(len(path_list)-1):
               p0, p1 = path_list[i][0], path_list[i+1][0]
               total_length += (np.linalg.norm(p0-p1)).sum()
        return total_length

Fast Marching Method and Level Set Method resources:

http://math.berkeley.edu/~sethian/

MIT video lecture on Level set and fast marching methods: http://ocw.mit.edu/courses/mathematics/18-086-mathematical-methods-for-engineers-ii-spring-2006/video-lectures/lecture-11-level-set-method/

http://www.mathworks.com/matlabcentral/fileexchange/24531

http://www.mathworks.com/matlabcentral/fileexchange/6110

http://ktchu.serendipityresearch.org/software/lsmlib/index.html