resample

resample — shrink, expand, rotate with a choice of interpolators

Stability Level

Stable, unless otherwise indicated

Functions

int vips_shrink ()
int vips_similarity ()
int vips_resize ()
int vips_affine ()
int vips_quadratic ()

Object Hierarchy


Includes

#include <vips/vips.h>

Description

Resample an image in various ways, using a VipsInterpolate to generate intermediate values.

Functions

vips_shrink ()

int
vips_shrink (VipsImage *in,
             VipsImage **out,
             double xshrink,
             double yshrink,
             ...);

Shrink in by a pair of factors with a simple box filter.

You will get aliasing for non-integer shrinks. In this case, shrink with this function to the nearest integer size above the target shrink, then downsample to the exact size with vips_affine() and your choice of interpolator.

See also: vips_affine().

Parameters

in

input image

 

out

output image

 

xshrink

horizontal shrink

 

yshrink

vertical shrink

 

...

NULL-terminated list of optional named arguments

 

Returns

0 on success, -1 on error


vips_similarity ()

int
vips_similarity (VipsImage *in,
                 VipsImage **out,
                 ...);

Optional arguments:

scale : scale by this factor angle : rotate by this many degrees anticlockwise interpolate : interpolate pixels with this idx : input horizontal offset idy : input vertical offset odx : output horizontal offset ody : output vertical offset

This operator calls vips_affine() for you, calculating the matrix for the affine transform from scale and angle . Other parameters are passed on to vips_affine() unaltered.

See also: vips_affine(), VipsInterpolate.

Parameters

in

input image

 

out

output image

 

...

NULL-terminated list of optional named arguments

 

Returns

0 on success, -1 on error


vips_resize ()

int
vips_resize (VipsImage *in,
             VipsImage **out,
             double scale,
             ...);

Optional arguments:

interpolate : interpolate pixels with this idx : input horizontal offset idy : input vertical offset

Resize an image. When upsizing (scale > 1), the image is simply resized with vips_affine() and the supplied interpolate . When downsizing, the image is block-shrunk with vips_shrink() to roughly half the interpolator window size above the target size, then blurred with an anti-alias filter, then resampled with vips_affine() and the supplied interpolator, then sharpened.

interpolate defaults to bucubic, or bilinear if that is not available.

idx , idy default to zero. Offset them by 0.5 to get pixel-centre sampling.

See also: vips_shrink(), vips_affine(), VipsInterpolate.

Parameters

in

input image

 

out

output image

 

scale

scale factor

 

...

NULL-terminated list of optional named arguments

 

Returns

0 on success, -1 on error


vips_affine ()

int
vips_affine (VipsImage *in,
             VipsImage **out,
             double a,
             double b,
             double c,
             double d,
             ...);

Optional arguments:

interpolate : interpolate pixels with this oarea : output rectangle idx : input horizontal offset idy : input vertical offset odx : output horizontal offset ody : output vertical offset

This operator performs an affine transform on an image using interpolate .

The transform is:

X = a * (x + idx ) + b * (y + idy ) + odx Y = c * (x + idx ) + d * (y + idy ) + doy

x and y are the coordinates in input image. X and Y are the coordinates in output image. (0,0) is the upper left corner.

The section of the output space defined by oarea is written to out . oarea is a four-element int array of left, top, width, height. By default oarea is just large enough to cover the whole of the transformed input image.

interpolate defaults to bilinear.

idx , idy , odx , ody default to zero.

See also: vips_shrink(), VipsInterpolate.

Parameters

in

input image

 

out

output image

 

a

transformation matrix coefficient

 

b

transformation matrix coefficient

 

c

transformation matrix coefficient

 

d

transformation matrix coefficient

 

...

NULL-terminated list of optional named arguments

 

Returns

0 on success, -1 on error


vips_quadratic ()

int
vips_quadratic (VipsImage *in,
                VipsImage **out,
                VipsImage *coeff,
                ...);

Optional arguments:

interpolate : use this interpolator (default bilinear)

See also: vips_affine().

Parameters

in

input image

 

out

output image

 

coeff

horizontal quadratic

 

...

NULL-terminated list of optional named arguments

 

Returns

0 on success, -1 on error

Types and Values