def error_contour(self, phi, epsilon = 2.0, delta_phi = None):
"""Error between worm shape and contour from image given implicitly by phi
Arguments:
phi (array): implicit worm contour, if none calculated from actual shape
delta_phi (number): range of phi values to consider for error estimate
epsilon (number): refularization parameter for the step functions
curvature (bool): error due to curvature on phi
"""
phi2 = self.phi(size = phi.shape);
if delta_phi is None:
error = np.sum((np.tanh(phi / epsilon)-np.tanh(phi2 / epsilon))**2);
else:
idx = np.flatnonzero(np.logical_and(phi2 <= delta_phi, phi2 >= -delta_phi))
error =np.sum((np.tanh(phi[idx] / epsilon)-np.tanh(phi2[idx] / epsilon))**2);
return error;
评论列表
文章目录