def get_mask(img, axis=None):
    """Detect regions of interest in a thresholded image

    Receive a thresholded single-channel image as a 2D uint8 numpy array.
    Assuming white background, get a mask vector
    indicating rows or columns (depending on the argument to `axis`)
    that contain any number of non-white pixels. Return the mask vector
    as a 1D boolean numpy array.

    Note: The speed of the implementation allowed for quickly
    processing sheets of characters into >120,000 separate
    characters labeled for training/validating dataset.
    """

    if axis not in (0, 1):
        raise ValueError('missing or invalid argument to `axis`')

    return (img != 255).any(axis=axis)