Vips.Image.switch
Description: Reference for Vips.Image.switch

### Function

# Vips Imageswitch

#### Declaration [src]

    int
    vips_switch (
      VipsImage** tests,
      VipsImage** out,
      int n,
      ...
    )

#### Description [src]

The `tests` images are evaluated and at each point the index of the first non-zero value is written to `out`. If all `tests` are false, the value (`n` + 1) is written.

Images in `tests` must have one band. They are expanded to the bounding box of the set of images in `tests`, and that size is used for `out`. `tests` can have up to 255 elements.

Combine with `vips_case()` to make an efficient multi-way `vips_ifthenelse()`.

See also

`vips_maplut()`, `vips_case()`, `vips_ifthenelse()`.

This function is not directly available to language bindings.

#### Parameters

`tests`

  Type: An array of `VipsImage*`

  Test these images.

  The length of the array is specified in the `n` argument.
  The data is owned by the caller of the function.

`out`

  Type: `VipsImage`

  Output index image.

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

`n`

  Type: `int`

  Number of input images.

`...`

  Type: ``

  `NULL`-terminated list of optional named arguments.

#### Return value

Type: `int`

0 on success, -1 on error.