def _find_boundaries_subpixel(label_img):
    'See ``find_boundaries(..., mode=\'subpixel\')``.\n\n    Notes\n    -----\n    This function puts in an empty row and column between each *actual*\n    row and column of the image, for a corresponding shape of $2s - 1$\n    for every image dimension of size $s$. These "interstitial" rows\n    and columns are filled as ``True`` if they separate two labels in\n    `label_img`, ``False`` otherwise.\n\n    I used ``view_as_windows`` to get the neighborhood of each pixel.\n    Then I check whether there are two labels or more in that\n    neighborhood.\n    '
    ndim = label_img.ndim
    max_label = np.iinfo(label_img.dtype).max
    label_img_expanded = np.zeros([((2 * s) - 1) for s in label_img.shape], label_img.dtype)
    pixels = ((slice(None, None, 2),) * ndim)
    label_img_expanded[pixels] = label_img
    edges = np.ones(label_img_expanded.shape, dtype=bool)
    edges[pixels] = False
    label_img_expanded[edges] = max_label
    windows = view_as_windows(np.pad(label_img_expanded, 1, mode='constant', constant_values=0), ((3,) * ndim))
    boundaries = np.zeros_like(edges)
    for index in np.ndindex(label_img_expanded.shape):
        if edges[index]:
            values = np.unique(windows[index].ravel())
            if (len(values) > 2):
                boundaries[index] = True
    return boundaries
See ``find_boundaries(..., mode='subpixel')``.

Notes
-----
This function puts in an empty row and column between each *actual*
row and column of the image, for a corresponding shape of $2s - 1$
for every image dimension of size $s$. These "interstitial" rows
and columns are filled as ``True`` if they separate two labels in
`label_img`, ``False`` otherwise.

I used ``view_as_windows`` to get the neighborhood of each pixel.
Then I check whether there are two labels or more in that
neighborhood.
def _find_boundaries_subpixel(label_img):
    'See ``find_boundaries(..., mode=\'subpixel\')``.\n\n    Notes\n    -----\n    This function puts in an empty row and column between each *actual*\n    row and column of the image, for a corresponding shape of $2s - 1$\n    for every image dimension of size $s$. These "interstitial" rows\n    and columns are filled as ``True`` if they separate two labels in\n    `label_img`, ``False`` otherwise.\n\n    I used ``view_as_windows`` to get the neighborhood of each pixel.\n    Then I check whether there are two labels or more in that\n    neighborhood.\n    '
    ndim = label_img.ndim
    max_label = np.iinfo(label_img.dtype).max
    label_img_expanded = np.zeros([((2 * s) - 1) for s in label_img.shape], label_img.dtype)
    pixels = ((slice(None, None, 2),) * ndim)
    label_img_expanded[pixels] = label_img
    edges = np.ones(label_img_expanded.shape, dtype=bool)
    edges[pixels] = False
    label_img_expanded[edges] = max_label
    windows = view_as_windows(np.pad(label_img_expanded, 1, mode='constant', constant_values=0), ((3,) * ndim))
    boundaries = np.zeros_like(edges)
    for index in np.ndindex(label_img_expanded.shape):
        if edges[index]:
            values = np.unique(windows[index].ravel())
            if (len(values) > 2):
                boundaries[index] = True
    return boundaries