---
name: "im_thresh"
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_thresh"
---

# im\_thresh(3)

threshold an image

## NAME

im\_thresh, im\_slice - threshold an image

## SYNOPSIS

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

int im\_thresh(in, out, threshold)\
 IMAGE \*in, \*out;\
 double threshold;

int im\_slice(in, out, threshold1, threshold2)\
 IMAGE \*in, \*out;\
 double threshold1, threshold2;

## DESCRIPTION

These functions have been replaced with the relational and boolean packages - see  **im\_lessconst()** and  **im\_and()** for much better ways of doing this.

These functions operate on any non-complex input.  The output image is a unsigned char image with the same sizes and the same number of channels as input.

im\_slice() thresholds the image held by image descriptor in and writes the result on the image descriptor out.  Output is a byte image with values less than threshold1) set to 0, values in \[threshold1, threshold2) set to 128 and values greater than threshold2 set to 255  (x in range \[a,b) means a\<=x\<b).

im\_threshold() thresholds the image held by image descriptor in and writes the result on the image descriptor out.  Output is a byte image with values less than threshold set to 0, and values greater or equal to threshold set to 255.

## RETURN VALUE

The function returns 0 on success and -1 on error.

## SEE ALSO

[im\_dilate(3)](/im_dilate/3.md), [im\_erode(3)](/im_erode/3.md), [im\_lessconst(3)](/im_lessconst/3.md), im\_and(3).

## COPYRIGHT

N. Dessipris,

## AUTHOR

N. Dessipris - 26/04/1991
