def binary_thin(x, max_iter=None):
    '\n    Binary thinning morphological operation\n\n    :param x: a binary image, or an image that is to be converted to a binary image\n    :param max_iter: maximum number of iterations; default is `None` that results in an infinite\n    number of iterations (note that `binary_thin` will automatically terminate when no more changes occur)\n    :return:\n    '
    thin1 = _thin_iter_1_lut()
    thin2 = _thin_iter_2_lut()
    thin1_mut = _lut_mutate_mask(thin1)
    thin2_mut = _lut_mutate_mask(thin2)
    iter_count = 0
    while ((max_iter is None) or (iter_count < max_iter)):
        lut_indices = binary_image_to_lut_indices(x)
        x_mut = thin1_mut[lut_indices]
        if (x_mut.sum() == 0):
            break
        x = thin1[lut_indices]
        lut_indices = binary_image_to_lut_indices(x)
        x_mut = thin2_mut[lut_indices]
        if (x_mut.sum() == 0):
            break
        x = thin2[lut_indices]
        iter_count += 1
    return x
Binary thinning morphological operation

:param x: a binary image, or an image that is to be converted to a binary image
:param max_iter: maximum number of iterations; default is `None` that results in an infinite
number of iterations (note that `binary_thin` will automatically terminate when no more changes occur)
:return:
def binary_thin(x, max_iter=None):
    '\n    Binary thinning morphological operation\n\n    :param x: a binary image, or an image that is to be converted to a binary image\n    :param max_iter: maximum number of iterations; default is `None` that results in an infinite\n    number of iterations (note that `binary_thin` will automatically terminate when no more changes occur)\n    :return:\n    '
    thin1 = _thin_iter_1_lut()
    thin2 = _thin_iter_2_lut()
    thin1_mut = _lut_mutate_mask(thin1)
    thin2_mut = _lut_mutate_mask(thin2)
    iter_count = 0
    while ((max_iter is None) or (iter_count < max_iter)):
        lut_indices = binary_image_to_lut_indices(x)
        x_mut = thin1_mut[lut_indices]
        if (x_mut.sum() == 0):
            break
        x = thin1[lut_indices]
        lut_indices = binary_image_to_lut_indices(x)
        x_mut = thin2_mut[lut_indices]
        if (x_mut.sum() == 0):
            break
        x = thin2[lut_indices]
        iter_count += 1
    return x