The triangle binarization algorithm