Yen binary thresholding algorithm