Vips.Image.mapim

### Method

# Vips Imagemapim

#### Declaration [src]

    int
    vips_mapim (
      VipsImage* in,
      VipsImage** out,
      VipsImage* index,
      ...
    )

#### Description [src]

This operator resamples `in` using `index` to look up pixels.

`out` is the same size as `index`, with each pixel being fetched from that position in `in`. That is:

    out[x, y] = in[index[x, y]]

If `index` has one band, that band must be complex. Otherwise, `index` must have two bands of any format.

Coordinates in `index` are in pixels, with (0, 0) being the top-left corner of `in`, and with y increasing down the image. Use `vips_xyz()` to build index images.

`interpolate` defaults to bilinear.

By default, new pixels are filled with `background`. This defaults to zero (black). You can set other extend types with `extend`. `VIPS_EXTEND_COPY` is better for image upsizing.

Image are normally treated as unpremultiplied, so this operation can be used directly on PNG images. If your images have been through `vips_premultiply()`, set `premultiplied`.

This operation does not change xres or yres. The image resolution needs to be updated by the application.

See `vips_maplut()` for a 1D equivalent of this operation.

Optional arguments

- `interpolate`: `VipsInterpolate`, interpolate pixels with this
- `extend`: `VipsExtend`, how to generate new pixels
- `background`: `VipsArrayDouble`, colour for new pixels
- `premultiplied`: `gboolean`, images are already premultiplied

See also

`vips_xyz()`, `vips_affine()`, `vips_resize()`, `vips_maplut()`, `VipsInterpolate`.

This method is not directly available to language bindings.

#### Parameters

`out`

  Type: `VipsImage`

  Output image.

  The argument will be set by the function.
  The caller of the method takes ownership of the returned data, and is responsible for freeing it.

`index`

  Type: `VipsImage`

  Index image.

  The data is owned by the caller of the method.

`...`

  Type: ``

  `NULL`-terminated list of optional named arguments.

#### Return value

Type: `int`

0 on success, -1 on error.