T-snake algorithm for contour extraction and structural changes