Dynamic Programming Approach to Image Segmentation and its Application to Pre-processing of Mammograms