Binarizer: Fix off-by-one error and treat image borders specially