Segmentation using optimal partitioning and function pruning
