added segmentation code as well as 2D smoothing filter