Segmentation of touching or overlapping patterns in the image field