Working code for both active contour and mean shift