### Method

# Vips Image spcor

#### Declaration [src]

    int
    vips_spcor (
      VipsImage* in,
      VipsImage* ref,
      VipsImage** out,
      ...
    )

#### Description [src]

Calculate a correlation surface.

`ref` is placed at every position in `in` and the correlation coefficient calculated. The output image is always float.

The output image is the same size as the input. Extra input edge pixels are made by copying the existing edges outwards.

The correlation coefficient is calculated as:

             sumij (ref(i,j)-mean(ref))(inkl(i,j)-mean(inkl))
    c(k,l) = ------------------------------------------------
             sqrt(sumij (ref(i,j)-mean(ref))^2) *
                         sqrt(sumij (inkl(i,j)-mean(inkl))^2)

where inkl is the area of `in` centred at position (k,l).

from Niblack “An Introduction to Digital Image Processing”, Prentice/Hall, pp 138.

If the number of bands differs, one of the images must have one band. In this case, an n-band image is formed from the one-band image by joining n copies of the one-band image together, and then the two n-band images are operated upon.

The output image is always float, unless either of the two inputs is double, in which case the output is also double.

See also

`vips_fastcor()`.

This method is not directly available to language bindings.

#### Parameters

`ref`

  Type: `VipsImage`

  Reference image.

  The data is owned by the caller of the method.

`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.

`...`

  Type: ``

  `NULL`-terminated list of optional named arguments.

#### Return value

Type: `int`

0 on success, -1 on error.