def _stack_operation(stack, function, *args, **kwargs):
    """
    Perform an operation for all images of an image stack.

    This is just a wrapper for a function which can perform a procedure for one image to
    perform it for all images of a stack instead.

    Parameters
    ----------
    stack: ImageStack
        The image stack the function should be performed on
    function: function
        A function which takes ONE image as input and returns ONE image
    args:
        args are forwarded to the function.
    kwargs:
        kwargs are forwarded to the function.
    """
    for ind, img in enumerate(stack):
        stack[ind] = function(img, *args, **kwargs)
    return stack