def createStructuringElement(radius=1, neighborhood="8N"):
    """Create a structuring element function based on the neighborhood and the radius.

    Args:

        radius (integer): The radius of the structuring element excluding the center pixel.
        neighborhood (string): 4N or 8N neighborhood definition around the center pixel. 
    
    Returns:

        getStructuringElement (function): A function, which returns the neighborhood for a given center based on the configured radius and neighboorhood definition.
    """
    def getStructuringElement(center):
        """Create a set of pixel coordinates for all neighbor elements.
        
        Args:

            center (number tuple): A pixel coordinate tuple of the center pixel of the structuring element.

        Returns:

            setImg (number tuple set): A set of the foreground pixel coordinate tuples that make up the neighboorhood for the given center.
        """
        neighbors = set()
        if neighborhood == "4N":
            for x in range(center[0]-radius, center[0]+radius+1):
                for y in range(center[1]-radius, center[1]+radius+1):
                    if abs(center[0] - x) + abs(center[1] - y) <= radius:
                        neighbors.add((x, y))
        else:
            for x in range(center[0]-radius, center[0]+radius+1):
                for y in range(center[1]-radius, center[1]+radius+1):
                    neighbors.add((x, y))
        return neighbors
    # Use partial application of function arguments to dynamically calculate the neighborhood based on previous constraints.
    return getStructuringElement