An Improved Filter based on User-Supplied Function for Image Segmentation Purpose