def map_values(image, dictionary):
    """
    Modify image by swapping dictionary keys to dictionary values.
    @param image: Numpy ndarray of an image (usually label map patch).
    @param dictionary: dict(int => int). Keys in image are swapped to corresponding values.
    @return:
    """
    template = image.copy()  # Copy image so all values not in dict are unmodified
    for key, value in dictionary.items():
        template[image == key] = value

    return template