---
name: "im_similarity"
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_similarity_area"
---

# im\_similarity(3)

apply a similarity transform to an image

Part of [im\_similarity\_area(3)](/im_similarity_area/3.md).

## NAME

im\_similarity\_area, im\_similarity - apply a similarity transform to an image

## SYNOPSIS

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

int im\_similarity\_area(in, out, s, a, dx, dy, x, y, w, h)\
 **IMAGE \*in, \*out;**\
 **double s, a, dx, dy;**\
 **int x, y;**\
 **int w, h;**

int im\_similarity(in, out, s, a, dx, dy)\
 **IMAGE \*in, \*out;**\
 **double s, a, dx, dy;**

## DESCRIPTION

**im\_similarity\_area()** applies a similarity transformation on the image held by the IMAGE descriptor in and puts the result at the location pointed by the IMAGE descriptor out. in many have any number of bands, be any size, and have any non-complex type.

The transformation is described by s, a, dx, dy.  The point (x,y) in the input is mapped onto point (X,Y) in the output by

	X = s \* x - a \* y + dx\
 	Y = a \* x + s \* y + dy

s and a do not correspond to scale and angle of the transformation; the actual scale and angle are given by the equations:

	scale = sqrt(s\*s + a\*a) \
 	angle = arctan(s/a).

The area of the output image given by x, y, w, h is generated. (0,0) is  the position of the transformed top-left-hand corner of the input image. Function im\_similarity\_area resamples the transformed image using bilinear interpolation.

im\_similarity works exactly as im\_similarity\_area, but calculates x, y, w, h for you such that the rectangle described just encloses all of the transformed input pixels.

## RETURN VALUE

The functions return 0 on success and -1 on error.

## BUGS

As with most resamplers, im\_similarity performs poorly at the edges of images.

## SEE ALSO

similarity(1), similarity\_area(1)

## AUTHORS

N. Dessipris - 13/01/1992\
 J.Ph. Laurent - 12/12/92\
 J. Cupitt - 22/02/93
