Thresholding the image