def warp(image, p, model, sampler):
    """
    Warps an image.
    """
    coords = register.Coordinates(
        [0, image.shape[0], 0, image.shape[1]]
        )
    
    model = model(coords)
    sampler = sampler(coords)

    return sampler.f(image,
                     model.warp(p)
                    ).reshape(image.shape)
def warp(image, p, model, sampler):
    """
    Warps an image given a deformation model a set of parameters.

    @param image: an numpy ndarray.
    @param p: warp parameters.
    @param model: a deformation model.

    """
    coords = register.Coordinates(
        [0, image.shape[0], 0, image.shape[1]]
        )
    
    model = model(coords)
    sampler = sampler(coords)

    return sampler.f(image,
                     model.warp(p)
                    ).reshape(image.shape)