Gray image threshold segmentation