import importlib


def call_module_function(*arguments):
    """ Dynamically calls specified function from specified package and module, on the given image. The three arguments
    of the function represent, in order: the input image, any extra input images (necessary in the case of many-to-
    operations, empty otherwise) and the parameters dictionary to be given to the call
    """
    # Unwind parameters and gather the operation details
    image, extra_inputs_dict, parameters_dict = arguments[0], arguments[1], arguments[2]
    package, module, function = parameters_dict['function'].split('.')
    parameters = parameters_dict['params']

    # Call the requested function on the image
    imported_module = importlib.import_module('backend.' + package + '.' + module)
    results = getattr(imported_module, function)(image, extra_inputs_dict, parameters)

    return results