---
name: "im_invertlut"
section: "3"
platform: "linux"
package: "libvips-dev"
version: "7.20.7-1+b3"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/im_invertlut"
---

# im\_invertlut(3)

turn a set of greyscale measurements into a gamma-correcting LUT

## NAME

im\_invertlut - turn a set of greyscale measurements into a gamma-correcting LUT

## SYNOPSIS

\#include \<vips/vips.h\>

int\
 im\_invertlut( DOUBLEMASK \*input, IMAGE \*output, int lut\_size )

## DESCRIPTION

Given a mask of target values and real values, generate a LUT which will map reals to targets. Handy for linearising images from measurements of a colour chart. All values in \[0,1\]. Extrapolate head and tail to 0 and 1.

Eg. input like:

  4 3\
   0\.1  0.2  0.3  0.1\
   0\.2  0.4  0.4  0.2\
   0\.7  0.5  0.6  0.3

means a patch with 10% reflectance produces an image with 20% in channel 1, 30% in channel 2, and 10% in channel 3. A patch with 20% reflectance makes an image with 40% red, 40% green and 20% blue, and so on.

Inputs don't need to be sorted (we do that). Generate any precision LUT ... typically ask for 256 elements.

It won't work too well for non-monotonic camera responses (should fix this).

Interpolation is simple piecewise linear; ought to do something better really.

## RETURN VALUE

\-1 on error, otherwise 0

## SEE ALSO

[im\_histgr(3)](/im_histgr/3.md), [im\_hsp(3)](/im_hsp/3.md), [im\_heq(3)](/im_heq/3.md), [im\_identity(3)](/im_identity/3.md).

## COPYRIGHT

2001, National Gallery
