---
name: "im_stdif"
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_stdif"
---

# im\_stdif(3)

statistical differentiation of an image

## NAME

im\_stdif, im\_stdif\_raw - statistical differentiation of an image

## SYNOPSIS

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

int im\_stdif(in, out, a, m0, b, s0, xw, yw)\
 IMAGE \*in, \*out;\
 double a, m0, b, s0;\
 int xw, yw;

int im\_stdif\_raw(in, out, a, m0, b, s0, xw, yw)\
 IMAGE \*in, \*out;\
 double a, m0, b, s0;\
 int xw, yw;

## DESCRIPTION

im\_stdif() preforms statistical differencing according to the formula given in page 45 of the book "An Introduction to Digital Image Processing" by Wayne Niblack. This transformation emphasises the way in which a pel differs statistically from its neighbours. It is useful for enhancing low-contrast images with lots of detail, such as X-ray plates.

At point (i,j) the output is given by the eqn:

  vout(i,j) = a\*m0 + (1-a)\*meanv + \
           (vin(i,j) - meanv) \* (b\*s0) / (s0+b\*stdv)

Values a, m0, b and s0 are entered, while meanv and stdv are the values calculated over a moving window of size xw, yw centred on pixel (i,j). m0 is the new mean, a is the weight given to it. s0 is the new standard deviation, b is the weight given to it. Try:

  im\_stdif $VIPSHOME/pics/huysum.v fred.v 0.5 128 0.5 50 11 11

The opreation works on one-band UCHAR images only, and writes a one-band UCHAR image as its result. The output image has the same size as the input - a black border is added to mark uncomputable pixels.

im\_stdif\_raw() behaves exactly as im\_stdif(), but does not add the border of black pixels.

## RETURN VALUE

All functions returns 0 on success and -1 on error.

## SEE ALSO

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

## COPYRIGHT

1991-1996, The National Gallery and Birkbeck College
