Top |
Functions
Types and Values
enum | VipsOperationMath |
enum | VipsOperationMath2 |
enum | VipsOperationRound |
enum | VipsOperationRelational |
enum | VipsOperationBoolean |
enum | VipsOperationComplex |
enum | VipsOperationComplex2 |
enum | VipsOperationComplexget |
Description
These operations perform pixel arithmetic, that is, they perform an arithmetic operation, such as addition, on every pixel in an image or a pair of images. All (except in a few cases noted below) will work with images of any type or any mixture of types, of any size and of any number of bands.
For binary operations, 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.
In the same way, for operations that take an array constant, such as
vips_remainder_const()
, you can mix single-element arrays or single-band
images freely.
Arithmetic operations try to preserve precision by increasing the number of
bits in the output image when necessary. Generally, this follows the ANSI C
conventions for type promotion, so multiplying two
VIPS_FORMAT_UCHAR images together, for example, produces a
VIPS_FORMAT_USHORT image, and taking the vips_cos()
of a
VIPS_FORMAT_USHORT image produces VIPS_FORMAT_FLOAT image.
For binary arithmetic operations, type promotion occurs in two stages. First, the two input images are cast up to the smallest common format, that is, the type with the smallest range that can represent the full range of both inputs. This conversion can be represented as a table:
Table 3. Smallest common format
in2 /in1
|
uchar | char | ushort | short | uint | int | float | double | complex | double complex |
---|---|---|---|---|---|---|---|---|---|---|
uchar | ushort | short | ushort | short | uint | int | float | double | complex | double complex |
char | short | short | short | short | int | int | float | double | complex | double complex |
ushort | ushort | short | ushort | short | uint | int | float | double | complex | double complex |
short | short | short | short | short | int | int | float | double | complex | double complex |
uint | uint | int | uint | int | uint | int | float | double | complex | double complex |
int | int | int | int | int | int | int | float | double | complex | double complex |
float | float | float | float | float | float | float | float | double | complex | double complex |
double | double | double | double | double | double | double | double | double | double complex | double complex |
complex | complex | complex | complex | complex | complex | complex | complex | double complex | complex | double complex |
double complex | double complex | double complex | double complex | double complex | double complex | double complex | double complex | double complex | double complex | double complex |
In the second stage, the operation is performed between the two identical types to form the output. The details vary between operations, but generally the principle is that the output type should be large enough to represent the whole range of possible values, except that int never becomes float.
Functions
vips_add ()
int vips_add (VipsImage *left
,VipsImage *right
,VipsImage **out
,...
);
This operation calculates in1
+ in2
and writes the result to out
.
If the images differ in size, the smaller image is enlarged to match the larger by adding zero pixels along the bottom and right.
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 two input images are cast up to the smallest common format (see table Smallest common format in
arithmetic), then thefollowing table is used to determine the output type:
Table 4. VipsAdd type promotion
input type | output type |
---|---|
uchar | ushort |
char | short |
ushort | uint |
short | int |
uint | uint |
int | int |
float | float |
double | double |
complex | complex |
double complex | double complex |
In other words, the output type is just large enough to hold the whole range of possible values.
Operations on integer images are performed using the processor's vector unit, if possible. Disable this with --vips-novector or VIPS_NOVECTOR.
See also: vips_subtract()
, vips_linear()
.
vips_sum ()
int vips_sum (VipsImage **in
,VipsImage **out
,int n
,...
);
This operation sums all images in in
and writes the result to out
.
If the images differ in size, the smaller images are enlarged to match the largest by adding zero pixels along the bottom and right.
If the number of bands differs, all but one of the images must have one band. In this case, n-band images are formed from the one-band images by joining n copies of the one-band images together, and then the n-band images are operated upon.
The input images are cast up to the smallest common format (see table Smallest common format in
arithmetic), then thefollowing table is used to determine the output type:
Table 5. VipsSum type promotion
input type | output type |
---|---|
uchar | uint |
char | int |
ushort | uint |
short | int |
uint | uint |
int | int |
float | float |
double | double |
complex | complex |
double complex | double complex |
In other words, the output type is just large enough to hold the whole range of possible values.
See also: vips_add()
.
vips_subtract ()
int vips_subtract (VipsImage *in1
,VipsImage *in2
,VipsImage **out
,...
);
This operation calculates in1
- in2
and writes the result to out
.
If the images differ in size, the smaller image is enlarged to match the larger by adding zero pixels along the bottom and right.
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 two input images are cast up to the smallest common format (see table Smallest common format in
arithmetic), then thefollowing table is used to determine the output type:
Table 6. VipsSubtract type promotion
input type | output type |
---|---|
uchar | short |
char | short |
ushort | int |
short | int |
uint | int |
int | int |
float | float |
double | double |
complex | complex |
double complex | double complex |
In other words, the output type is just large enough to hold the whole range of possible values.
See also: vips_add()
, vips_linear()
.
vips_multiply ()
int vips_multiply (VipsImage *left
,VipsImage *right
,VipsImage **out
,...
);
This operation calculates left
* right
and writes the result to out
.
If the images differ in size, the smaller image is enlarged to match the larger by adding zero pixels along the bottom and right.
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 two input images are cast up to the smallest common format (see table Smallest common format in
arithmetic), then thefollowing table is used to determine the output type:
Table 7. VipsMultiply type promotion
input type | output type |
---|---|
uchar | ushort |
char | short |
ushort | uint |
short | int |
uint | uint |
int | int |
float | float |
double | double |
complex | complex |
double complex | double complex |
In other words, the output type is just large enough to hold the whole range of possible values.
See also: vips_add()
, vips_linear()
.
vips_divide ()
int vips_divide (VipsImage *left
,VipsImage *right
,VipsImage **out
,...
);
This operation calculates in1
/ in2
and writes the result to out
. If any
pixels in in2
are zero, the corresponding pixel in out
is also zero.
If the images differ in size, the smaller image is enlarged to match the larger by adding zero pixels along the bottom and right.
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 two input images are cast up to the smallest common format (see table Smallest common format in
arithmetic), then thefollowing table is used to determine the output type:
Table 8. vips_divide()
type promotion
input type | output type |
---|---|
uchar | float |
char | float |
ushort | float |
short | float |
uint | float |
int | float |
float | float |
double | double |
complex | complex |
double complex | double complex |
In other words, the output type is just large enough to hold the whole range of possible values.
See also: vips_multiply()
, vips_linear()
, vips_pow()
.
vips_linear ()
int vips_linear (VipsImage *in
,VipsImage **out
,const double *a
,const double *b
,int n
,...
);
Optional arguments:
uchar
: output uchar pixels
Pass an image through a linear transform, ie. (out
= in
* a
+ b
). Output
is float for integer input, double for double input, complex for
complex input and double complex for double complex input. Set uchar
to
output uchar pixels.
If the arrays of constants have just one element, that constant is used for all image bands. If the arrays have more than one element and they have the same number of elements as there are bands in the image, then one array element is used for each band. If the arrays have more than one element and the image only has a single band, the result is a many-band image where each band corresponds to one array element.
See also: vips_linear1()
, vips_add()
.
[method]
vips_linear1 ()
int vips_linear1 (VipsImage *in
,VipsImage **out
,double a
,double b
,...
);
Optional arguments:
uchar
: output uchar pixels
Run vips_linear()
with a single constant.
See also: vips_linear()
.
[method]
vips_remainder ()
int vips_remainder (VipsImage *left
,VipsImage *right
,VipsImage **out
,...
);
This operation calculates left
% right
(remainder after integer division)
and writes the result to out
. The images may have any
non-complex format. For float formats, vips_remainder()
calculates in1
-
in2
* floor (in1
/ in2
).
If the images differ in size, the smaller image is enlarged to match the larger by adding zero pixels along the bottom and right.
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 two input images are cast up to the smallest common format (see table Smallest common format in
arithmetic), and that format is theresult type.
See also: vips_remainder_const()
, vips_divide()
, vips_round()
.
vips_remainder_const ()
int vips_remainder_const (VipsImage *in
,VipsImage **out
,const double *c
,int n
,...
);
This operation calculates in
% c
(remainder after division by an
array of constants)
and writes the result to out
.
The image may have any
non-complex format. For float formats, vips_remainder_const()
calculates
in
- c
* floor (in
/ c
).
If the array of constants has just one element, that constant is used for all image bands. If the array has more than one element and they have the same number of elements as there are bands in the image, then one array element is used for each band. If the arrays have more than one element and the image only has a single band, the result is a many-band image where each band corresponds to one array element.
See also: vips_remainder()
, vips_divide()
, vips_round()
.
[method]
vips_remainder_const1 ()
int vips_remainder_const1 (VipsImage *in
,VipsImage **out
,double c
,...
);
This operation calculates in
% c
(remainder after division by a
constant)
and writes the result to out
.
The image may have any
non-complex format. For float formats, vips_remainder_const()
calculates
in
- c
* floor (in
/ c
).
If the array of constants has just one element, that constant is used for all image bands. If the array has more than one element and they have the same number of elements as there are bands in the image, then one array element is used for each band. If the arrays have more than one element and the image only has a single band, the result is a many-band image where each band corresponds to one array element.
See also: vips_remainder()
, vips_divide()
, vips_round()
.
[method]
vips_invert ()
int vips_invert (VipsImage *in
,VipsImage **out
,...
);
For unsigned formats, this operation calculates (max - in
), eg. (255 -
in
) for uchar. For signed and float formats, this operation calculates (-1
in
).
For complex images, only the real part is inverted. See also vips_conj()
.
See also: vips_linear()
.
[method]
vips_abs ()
int vips_abs (VipsImage *in
,VipsImage **out
,...
);
This operation finds the absolute value of an image. It does a copy for
unsigned integer types, negate for negative values in
signed integer types, fabs(3)
for
float types, and calculates modulus for complex
types.
See also: vips_sign()
.
[method]
vips_sign ()
int vips_sign (VipsImage *in
,VipsImage **out
,...
);
Finds the unit vector in the direction of the pixel value. For non-complex images, it returns a signed char image with values -1, 0, and 1 for negative, zero and positive pixels. For complex images, it returns a complex normalised to length 1.
See also: vips_abs()
.
[method]
vips_round ()
int vips_round (VipsImage *in
,VipsImage **out
,VipsOperationRound round
,...
);
Round to an integral value.
Copy for integer types, round float and complex types.
The format of out
is always the same as in
, so you may wish to cast to an
integer format afterwards.
See also: vips_cast()
[method]
Parameters
in |
input VipsImage |
|
out |
output VipsImage. |
[out] |
round |
VipsOperationRound rounding operation to perform |
|
... |
|
vips_floor ()
int vips_floor (VipsImage *in
,VipsImage **out
,...
);
Round to an integral value with VIPS_OPERATION_ROUND_FLOOR. See
vips_round()
.
[method]
vips_ceil ()
int vips_ceil (VipsImage *in
,VipsImage **out
,...
);
Round to an integral value with VIPS_OPERATION_ROUND_CEIL. See
vips_round()
.
[method]
vips_rint ()
int vips_rint (VipsImage *in
,VipsImage **out
,...
);
Round to an integral value with VIPS_OPERATION_ROUND_RINT. See
vips_round()
.
[method]
vips_math ()
int vips_math (VipsImage *in
,VipsImage **out
,VipsOperationMath math
,...
);
Perform various functions in -lm, the maths library, on images.
Angles are expressed in degrees. The output type is float unless the input is double, in which case the output is double.
Non-complex images only.
See also: vips_math2()
.
[method]
vips_sin ()
int vips_sin (VipsImage *in
,VipsImage **out
,...
);
Perform VIPS_OPERATION_MATH_SIN on an image. See vips_math()
.
[method]
vips_cos ()
int vips_cos (VipsImage *in
,VipsImage **out
,...
);
Perform VIPS_OPERATION_MATH_COS on an image. See vips_math()
.
[method]
vips_tan ()
int vips_tan (VipsImage *in
,VipsImage **out
,...
);
Perform VIPS_OPERATION_MATH_TAN on an image. See vips_math()
.
[method]
vips_asin ()
int vips_asin (VipsImage *in
,VipsImage **out
,...
);
Perform VIPS_OPERATION_MATH_ASIN on an image. See vips_math()
.
[method]
vips_acos ()
int vips_acos (VipsImage *in
,VipsImage **out
,...
);
Perform VIPS_OPERATION_MATH_ACOS on an image. See vips_math()
.
[method]
vips_atan ()
int vips_atan (VipsImage *in
,VipsImage **out
,...
);
Perform VIPS_OPERATION_MATH_ATAN on an image. See vips_math()
.
[method]
vips_exp ()
int vips_exp (VipsImage *in
,VipsImage **out
,...
);
Perform VIPS_OPERATION_MATH_EXP on an image. See vips_math()
.
[method]
vips_exp10 ()
int vips_exp10 (VipsImage *in
,VipsImage **out
,...
);
Perform VIPS_OPERATION_MATH_EXP10 on an image. See vips_math()
.
[method]
vips_log ()
int vips_log (VipsImage *in
,VipsImage **out
,...
);
Perform VIPS_OPERATION_MATH_LOG on an image. See vips_math()
.
[method]
vips_log10 ()
int vips_log10 (VipsImage *in
,VipsImage **out
,...
);
Perform VIPS_OPERATION_MATH_LOG10 on an image. See vips_math()
.
[method]
vips_complex ()
int vips_complex (VipsImage *in
,VipsImage **out
,VipsOperationComplex cmplx
,...
);
Perform various operations on complex images.
Angles are expressed in degrees. The output type is complex unless the input is double or dpcomplex, in which case the output is dpcomplex.
[method]
vips_polar ()
int vips_polar (VipsImage *in
,VipsImage **out
,...
);
Perform VIPS_OPERATION_COMPLEX_POLAR on an image. See vips_complex()
.
[method]
vips_rect ()
int vips_rect (VipsImage *in
,VipsImage **out
,...
);
Perform VIPS_OPERATION_COMPLEX_RECT on an image. See vips_complex()
.
[method]
vips_conj ()
int vips_conj (VipsImage *in
,VipsImage **out
,...
);
Perform VIPS_OPERATION_COMPLEX_CONJ on an image. See vips_complex()
.
[method]
vips_complex2 ()
int vips_complex2 (VipsImage *left
,VipsImage *right
,VipsImage **out
,VipsOperationComplex2 cmplx
,...
);
Perform various binary operations on complex images.
Angles are expressed in degrees. The output type is complex unless the input is double or dpcomplex, in which case the output is dpcomplex.
vips_cross_phase ()
int vips_cross_phase (VipsImage *left
,VipsImage *right
,VipsImage **out
,...
);
Perform VIPS_OPERATION_COMPLEX2_CROSS_PHASE on an image.
See vips_complex2()
.
vips_complexget ()
int vips_complexget (VipsImage *in
,VipsImage **out
,VipsOperationComplexget get
,...
);
Get components of complex images.
The output type is the same as the input type, except VIPS_FORMAT_COMPLEX becomes VIPS_FORMAT_FLOAT and VIPS_FORMAT_DPCOMPLEX becomes VIPS_FORMAT_DOUBLE.
[method]
vips_real ()
int vips_real (VipsImage *in
,VipsImage **out
,...
);
Perform VIPS_OPERATION_COMPLEXGET_REAL on an image. See vips_complexget()
.
[method]
vips_imag ()
int vips_imag (VipsImage *in
,VipsImage **out
,...
);
Perform VIPS_OPERATION_COMPLEXGET_IMAG on an image. See vips_complexget()
.
[method]
vips_complexform ()
int vips_complexform (VipsImage *left
,VipsImage *right
,VipsImage **out
,...
);
Compose two real images to make a complex image. If either left
or right
are VIPS_FORMAT_DOUBLE, out
is VIPS_FORMAT_DPCOMPLEX. Otherwise out
is VIPS_FORMAT_COMPLEX. left
becomes the real component of out
and
right
the imaginary.
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.
See also: vips_complexget()
.
vips_relational ()
int vips_relational (VipsImage *left
,VipsImage *right
,VipsImage **out
,VipsOperationRelational relational
,...
);
Perform various relational operations on pairs of images.
The output type is always uchar, with 0 for FALSE and 255 for TRUE.
Less-than and greater-than for complex images compare the modulus.
If the images differ in size, the smaller image is enlarged to match the larger by adding zero pixels along the bottom and right.
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 two input images are cast up to the smallest common format (see table Smallest common format in
arithmetic).To decide if pixels match exactly, that is have the same value in every
band, use vips_bandbool()
after this operation to AND or OR image bands
together.
See also: vips_boolean()
, vips_bandbool()
, vips_relational_const()
.
vips_equal ()
int vips_equal (VipsImage *left
,VipsImage *right
,VipsImage **out
,...
);
Perform VIPS_OPERATION_RELATIONAL_EQUAL on a pair of images. See
vips_relational()
.
vips_notequal ()
int vips_notequal (VipsImage *left
,VipsImage *right
,VipsImage **out
,...
);
Perform VIPS_OPERATION_RELATIONAL_NOTEQ on a pair of images. See
vips_relational()
.
vips_less ()
int vips_less (VipsImage *left
,VipsImage *right
,VipsImage **out
,...
);
Perform VIPS_OPERATION_RELATIONAL_LESS on a pair of images. See
vips_relational()
.
vips_lesseq ()
int vips_lesseq (VipsImage *left
,VipsImage *right
,VipsImage **out
,...
);
Perform VIPS_OPERATION_RELATIONAL_LESSEQ on a pair of images. See
vips_relational()
.
vips_more ()
int vips_more (VipsImage *left
,VipsImage *right
,VipsImage **out
,...
);
Perform VIPS_OPERATION_RELATIONAL_MORE on a pair of images. See
vips_relational()
.
vips_moreeq ()
int vips_moreeq (VipsImage *left
,VipsImage *right
,VipsImage **out
,...
);
Perform VIPS_OPERATION_RELATIONAL_MOREEQ on a pair of images. See
vips_relational()
.
vips_relational_const ()
int vips_relational_const (VipsImage *in
,VipsImage **out
,VipsOperationRelational relational
,const double *c
,int n
,...
);
Perform various relational operations on an image and an array of constants.
The output type is always uchar, with 0 for FALSE and 255 for TRUE.
If the array of constants has just one element, that constant is used for all image bands. If the array has more than one element and they have the same number of elements as there are bands in the image, then one array element is used for each band. If the arrays have more than one element and the image only has a single band, the result is a many-band image where each band corresponds to one array element.
See also: vips_boolean()
, vips_relational()
.
[method]
vips_equal_const ()
int vips_equal_const (VipsImage *in
,VipsImage **out
,const double *c
,int n
,...
);
Perform VIPS_OPERATION_RELATIONAL_EQUAL on an image and a constant. See
vips_relational_const()
.
[method]
vips_notequal_const ()
int vips_notequal_const (VipsImage *in
,VipsImage **out
,const double *c
,int n
,...
);
Perform VIPS_OPERATION_RELATIONAL_NOTEQ on an image and a constant. See
vips_relational_const()
.
[method]
vips_less_const ()
int vips_less_const (VipsImage *in
,VipsImage **out
,const double *c
,int n
,...
);
Perform VIPS_OPERATION_RELATIONAL_LESS on an image and a constant. See
vips_relational_const()
.
[method]
vips_lesseq_const ()
int vips_lesseq_const (VipsImage *in
,VipsImage **out
,const double *c
,int n
,...
);
Perform VIPS_OPERATION_RELATIONAL_LESSEQ on an image and a constant. See
vips_relational_const()
.
[method]
vips_more_const ()
int vips_more_const (VipsImage *in
,VipsImage **out
,const double *c
,int n
,...
);
Perform VIPS_OPERATION_RELATIONAL_MORE on an image and a constant. See
vips_relational_const()
.
[method]
vips_moreeq_const ()
int vips_moreeq_const (VipsImage *in
,VipsImage **out
,const double *c
,int n
,...
);
Perform VIPS_OPERATION_RELATIONAL_MOREEQ on an image and a constant. See
vips_relational_const()
.
[method]
vips_relational_const1 ()
int vips_relational_const1 (VipsImage *in
,VipsImage **out
,VipsOperationRelational relational
,double c
,...
);
Perform various relational operations on an image and a constant. See
vips_relational_const()
.
See also: vips_boolean()
, vips_relational()
.
[method]
vips_equal_const1 ()
int vips_equal_const1 (VipsImage *in
,VipsImage **out
,double c
,...
);
Perform VIPS_OPERATION_RELATIONAL_EQUAL on an image and a constant. See
vips_relational_const()
.
[method]
vips_notequal_const1 ()
int vips_notequal_const1 (VipsImage *in
,VipsImage **out
,double c
,...
);
Perform VIPS_OPERATION_RELATIONAL_NOTEQ on an image and a constant. See
vips_relational_const()
.
[method]
vips_less_const1 ()
int vips_less_const1 (VipsImage *in
,VipsImage **out
,double c
,...
);
Perform VIPS_OPERATION_RELATIONAL_LESS on an image and a constant. See
vips_relational_const()
.
[method]
vips_lesseq_const1 ()
int vips_lesseq_const1 (VipsImage *in
,VipsImage **out
,double c
,...
);
Perform VIPS_OPERATION_RELATIONAL_LESSEQ on an image and a constant. See
vips_relational_const()
.
[method]
vips_more_const1 ()
int vips_more_const1 (VipsImage *in
,VipsImage **out
,double c
,...
);
Perform VIPS_OPERATION_RELATIONAL_MORE on an image and a constant. See
vips_relational_const()
.
[method]
vips_moreeq_const1 ()
int vips_moreeq_const1 (VipsImage *in
,VipsImage **out
,double c
,...
);
Perform VIPS_OPERATION_RELATIONAL_MOREEQ on an image and a constant. See
vips_relational_const()
.
[method]
vips_boolean ()
int vips_boolean (VipsImage *left
,VipsImage *right
,VipsImage **out
,VipsOperationBoolean boolean
,...
);
Perform various boolean operations on pairs of images.
The output image is the same format as the upcast input images for integer types. Float types are cast to int before processing. Complex types are not supported.
If the images differ in size, the smaller image is enlarged to match the larger by adding zero pixels along the bottom and right.
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 two input images are cast up to the smallest common format (see table Smallest common format in
arithmetic).See also: vips_boolean_const()
.
vips_andimage ()
int vips_andimage (VipsImage *left
,VipsImage *right
,VipsImage **out
,...
);
Perform VIPS_OPERATION_BOOLEAN_AND on a pair of images. See
vips_boolean()
.
vips_orimage ()
int vips_orimage (VipsImage *left
,VipsImage *right
,VipsImage **out
,...
);
Perform VIPS_OPERATION_BOOLEAN_OR on a pair of images. See
vips_boolean()
.
vips_eorimage ()
int vips_eorimage (VipsImage *left
,VipsImage *right
,VipsImage **out
,...
);
Perform VIPS_OPERATION_BOOLEAN_EOR on a pair of images. See
vips_boolean()
.
vips_lshift ()
int vips_lshift (VipsImage *left
,VipsImage *right
,VipsImage **out
,...
);
Perform VIPS_OPERATION_BOOLEAN_LSHIFT on a pair of images. See
vips_boolean()
.
vips_rshift ()
int vips_rshift (VipsImage *left
,VipsImage *right
,VipsImage **out
,...
);
Perform VIPS_OPERATION_BOOLEAN_RSHIFT on a pair of images. See
vips_boolean()
.
vips_boolean_const ()
int vips_boolean_const (VipsImage *in
,VipsImage **out
,VipsOperationBoolean boolean
,const double *c
,int n
,...
);
Perform various boolean operations on an image against an array of constants.
The output type is always uchar, with 0 for FALSE and 255 for TRUE.
If the array of constants has just one element, that constant is used for all image bands. If the array has more than one element and they have the same number of elements as there are bands in the image, then one array element is used for each band. If the arrays have more than one element and the image only has a single band, the result is a many-band image where each band corresponds to one array element.
See also: vips_boolean()
, vips_boolean_const1()
.
[method]
vips_andimage_const ()
int vips_andimage_const (VipsImage *in
,VipsImage **out
,const double *c
,int n
,...
);
Perform VIPS_OPERATION_BOOLEAN_AND on an image and an array of constants.
See vips_boolean_const()
.
See also: vips_boolean()
, vips_boolean_const1()
.
[method]
vips_orimage_const ()
int vips_orimage_const (VipsImage *in
,VipsImage **out
,const double *c
,int n
,...
);
Perform VIPS_OPERATION_BOOLEAN_OR on an image and an array of constants.
See vips_boolean_const()
.
See also: vips_boolean()
, vips_boolean_const1()
.
[method]
vips_eorimage_const ()
int vips_eorimage_const (VipsImage *in
,VipsImage **out
,const double *c
,int n
,...
);
Perform VIPS_OPERATION_BOOLEAN_EOR on an image and an array of constants.
See vips_boolean_const()
.
See also: vips_boolean()
, vips_boolean_const1()
.
[method]
vips_lshift_const ()
int vips_lshift_const (VipsImage *in
,VipsImage **out
,const double *c
,int n
,...
);
Perform VIPS_OPERATION_BOOLEAN_LSHIFT on an image and an array of constants.
See vips_boolean_const()
.
See also: vips_boolean()
, vips_boolean_const1()
.
[method]
vips_rshift_const ()
int vips_rshift_const (VipsImage *in
,VipsImage **out
,const double *c
,int n
,...
);
Perform VIPS_OPERATION_BOOLEAN_LSHIFT on an image and an array of constants.
See vips_boolean_const()
.
See also: vips_boolean()
, vips_boolean_const1()
.
[method]
vips_boolean_const1 ()
int vips_boolean_const1 (VipsImage *in
,VipsImage **out
,VipsOperationBoolean boolean
,double c
,...
);
Perform various boolean operations on an image with a single constant. See
vips_boolean_const()
.
See also: vips_boolean()
, vips_boolean_const()
.
[method]
vips_andimage_const1 ()
int vips_andimage_const1 (VipsImage *in
,VipsImage **out
,double c
,...
);
Perform VIPS_OPERATION_BOOLEAN_AND on an image and a constant.
See vips_boolean_const1()
.
See also: vips_boolean()
, vips_boolean_const()
.
[method]
vips_orimage_const1 ()
int vips_orimage_const1 (VipsImage *in
,VipsImage **out
,double c
,...
);
Perform VIPS_OPERATION_BOOLEAN_OR on an image and a constant.
See vips_boolean_const1()
.
See also: vips_boolean()
, vips_boolean_const()
.
[method]
vips_eorimage_const1 ()
int vips_eorimage_const1 (VipsImage *in
,VipsImage **out
,double c
,...
);
Perform VIPS_OPERATION_BOOLEAN_EOR on an image and a constant.
See vips_boolean_const1()
.
See also: vips_boolean()
, vips_boolean_const()
.
[method]
vips_lshift_const1 ()
int vips_lshift_const1 (VipsImage *in
,VipsImage **out
,double c
,...
);
Perform VIPS_OPERATION_BOOLEAN_LSHIFT on an image and a constant.
See vips_boolean_const1()
.
See also: vips_boolean()
, vips_boolean_const()
.
[method]
vips_rshift_const1 ()
int vips_rshift_const1 (VipsImage *in
,VipsImage **out
,double c
,...
);
Perform VIPS_OPERATION_BOOLEAN_RSHIFT on an image and a constant.
See vips_boolean_const1()
.
See also: vips_boolean()
, vips_boolean_const()
.
[method]
vips_math2 ()
int vips_math2 (VipsImage *left
,VipsImage *right
,VipsImage **out
,VipsOperationMath2 math2
,...
);
This operation calculates a 2-ary maths operation on a pair of images
and writes the result to out
. The images may have any
non-complex format. out
is float except in the case that either of left
or right
are double, in which case out
is also double.
It detects division by zero, setting those pixels to zero in the output. Beware: it does this silently!
If the images differ in size, the smaller image is enlarged to match the larger by adding zero pixels along the bottom and right.
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 two input images are cast up to the smallest common format (see table Smallest common format in
arithmetic), and that format is theresult type.
See also: vips_math2_const()
.
vips_pow ()
int vips_pow (VipsImage *left
,VipsImage *right
,VipsImage **out
,...
);
Perform VIPS_OPERATION_MATH2_POW on a pair of images. See
vips_math2()
.
vips_wop ()
int vips_wop (VipsImage *left
,VipsImage *right
,VipsImage **out
,...
);
Perform VIPS_OPERATION_MATH2_WOP on a pair of images. See
vips_math2()
.
vips_math2_const ()
int vips_math2_const (VipsImage *in
,VipsImage **out
,VipsOperationMath2 math2
,const double *c
,int n
,...
);
This operation calculates various 2-ary maths operations on an image and
an array of constants and writes the result to out
.
The image may have any
non-complex format. out
is float except in the case that in
is double, in which case out
is also double.
It detects division by zero, setting those pixels to zero in the output. Beware: it does this silently!
If the array of constants has just one element, that constant is used for all image bands. If the array has more than one element and they have the same number of elements as there are bands in the image, then one array element is used for each band. If the arrays have more than one element and the image only has a single band, the result is a many-band image where each band corresponds to one array element.
See also: vips_math2()
, vips_math()
.
[method]
vips_pow_const ()
int vips_pow_const (VipsImage *in
,VipsImage **out
,const double *c
,int n
,...
);
Perform VIPS_OPERATION_MATH2_POW on an image and a constant. See
vips_math2_const()
.
[method]
vips_wop_const ()
int vips_wop_const (VipsImage *in
,VipsImage **out
,const double *c
,int n
,...
);
Perform VIPS_OPERATION_MATH2_WOP on an image and a constant. See
vips_math2_const()
.
[method]
vips_math2_const1 ()
int vips_math2_const1 (VipsImage *in
,VipsImage **out
,VipsOperationMath2 math2
,double c
,...
);
This operation calculates various 2-ary maths operations on an image and
a constant. See vips_math2_const()
.
[method]
vips_pow_const1 ()
int vips_pow_const1 (VipsImage *in
,VipsImage **out
,double c
,...
);
Perform VIPS_OPERATION_MATH2_POW on an image and a constant. See
vips_math2_const()
.
[method]
vips_wop_const1 ()
int vips_wop_const1 (VipsImage *in
,VipsImage **out
,double c
,...
);
Perform VIPS_OPERATION_MATH2_WOP on an image and a constant. See
vips_math2_const()
.
[method]
vips_avg ()
int vips_avg (VipsImage *in
,double *out
,...
);
This operation finds the average value in an image. It operates on all
bands of the input image: use vips_stats()
if you need to calculate an
average for each band. For complex images, return the average modulus.
See also: vips_stats()
, vips_bandmean()
, vips_deviate()
, vips_rank()
[method]
Parameters
in |
input VipsImage |
|
out |
output pixel average. |
[out] |
... |
|
vips_deviate ()
int vips_deviate (VipsImage *in
,double *out
,...
);
This operation finds the standard deviation of all pixels in in
. It
operates on all bands of the input image: use vips_stats()
if you need
to calculate an average for each band.
Non-complex images only.
See also: vips_avg()
, vips_stats()
..
[method]
Parameters
in |
input VipsImage |
|
out |
output pixel standard deviation. |
[out] |
... |
|
vips_min ()
int vips_min (VipsImage *in
,double *out
,...
);
Optional arguments:
x
: horizontal position of minimumy
: vertical position of minimumsize
: number of minima to findout_array
: return array of minimum valuesx_array
: corresponding horizontal positionsy_array
: corresponding vertical positions
This operation finds the minimum value in an image.
By default it finds the single smallest value. If size
is set >1, it will
find the size
smallest values. It will stop searching early if has found
enough values.
Equal values will be sorted by y then x.
It operates on all
bands of the input image: use vips_stats()
if you need to find an
minimum for each band.
For complex images, this operation finds the minimum modulus.
You can read out the position of the minimum with x
and y
. You can read
out arrays of the values and positions of the top size
minima with
out_array
, x_array
and y_array
.
These values are returned sorted from
smallest to largest.
If there are more than size
minima, the minima returned will be a random
selection of the minima in the image.
See also: vips_min()
, vips_stats()
.
[method]
Parameters
in |
input VipsImage |
|
out |
output pixel minimum. |
[out] |
... |
|
vips_max ()
int vips_max (VipsImage *in
,double *out
,...
);
Optional arguments:
x
: horizontal position of maximumy
: vertical position of maximumsize
: number of maxima to findout_array
: return array of maximum valuesx_array
: corresponding horizontal positionsy_array
: corresponding vertical positions
This operation finds the maximum value in an image.
By default it finds the single largest value. If size
is set >1, it will
find the size
largest values. It will stop searching early if has found
enough values.
Equal values will be sorted by y then x.
It operates on all
bands of the input image: use vips_stats()
if you need to find an
maximum for each band.
For complex images, this operation finds the maximum modulus.
You can read out the position of the maximum with x
and y
. You can read
out arrays of the values and positions of the top size
maxima with
out_array
, x_array
and y_array
. These values are returned sorted from
largest to smallest.
If there are more than size
maxima, the maxima returned will be a random
selection of the maxima in the image.
See also: vips_min()
, vips_stats()
.
[method]
Parameters
in |
input VipsImage |
|
out |
output pixel maximum. |
[out] |
... |
|
vips_stats ()
int vips_stats (VipsImage *in
,VipsImage **out
,...
);
Find many image statistics in a single pass through the data. out
is a
one-band VIPS_FORMAT_DOUBLE image of at least 10 columns by n + 1
(where n is number of bands in image in
)
rows. Columns are statistics, and are, in order: minimum, maximum, sum,
sum of squares, mean, standard deviation, x coordinate of minimum, y
coordinate of minimum, x coordinate of maximum, y coordinate of maximum.
Later versions of vips_stats()
may add more columns.
Row 0 has statistics for all bands together, row 1 has stats for band 1, and so on.
If there is more than one maxima or minima, one of them will be chosen at random.
See also: vips_avg()
, vips_min()
.
[method]
vips_measure ()
int vips_measure (VipsImage *in
,VipsImage **out
,int h
,int v
,...
);
Optional arguments:
left
: area of image containing charttop
: area of image containing chartwidth
: area of image containing chartheight
: area of image containing chart
Analyse a grid of colour patches, producing an array of patch averages. The mask has a row for each measured patch and a column for each image band. The operations issues a warning if any patch has a deviation more than 20% of the mean. Only the central 50% of each patch is averaged.
If the chart does not fill the whole image, use the optional left
, top
,
width
, height
arguments to indicate the
position of the chart.
See also: vips_avg()
, vips_deviate()
.
[method]
vips_find_trim ()
int vips_find_trim (VipsImage *in
,int *left
,int *top
,int *width
,int *height
,...
);
Optional arguments:
threshold
:gdouble
, background / object thresholdbackground
: VipsArrayDouble, background colour
Search in
for the bounding box of the non-background area.
Any alpha is flattened out, then the image is median-filtered, all the row
and column sums of the absolute
difference from background
are calculated in a
single pass, then the first row or column in each of the
four directions where the sum is greater than threshold
gives the bounding
box.
If the image is entirely background, vips_find_trim()
returns width
== 0
and height
== 0.
background
defaults to 255, or 65535 for 16-bit images. Set another value,
or use vips_getpoint()
to pick a value from an edge. You'll need to flatten
before vips_getpoint()
to get a correct background value.
threshold
defaults to 10.
The image needs to be at least 3x3 pixels in size.
See also: vips_getpoint()
, vips_extract_area()
, vips_smartcrop()
.
[method]
vips_getpoint ()
int vips_getpoint (VipsImage *in
,double **vector
,int *n
,int x
,int y
,...
);
Reads a single pixel on an image.
The pixel values are returned in vector
, the length of the
array in n
. You must free the array with g_free()
when you are done with
it.
See also: vips_draw_point()
.
[method]
vips_hist_find ()
int vips_hist_find (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
band
: band to equalise
Find the histogram of in
. Find the histogram for band band
(producing a
one-band histogram), or for all bands (producing an n-band histogram) if
band
is -1.
in
is cast to u8 or u16. out
is always u32.
See also: vips_hist_find_ndim()
, vips_hist_find_indexed()
.
[method]
vips_hist_find_ndim ()
int vips_hist_find_ndim (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
bins
: number of bins to make on each axis
Make a one, two or three dimensional histogram of a 1, 2 or
3 band image. Divide each axis into bins
bins .. ie.
output is 1 x bins, bins x bins, or bins x bins x bins bands.
bins
defaults to 10.
Images are cast to uchar or ushort before histogramming.
See also: vips_hist_find()
, vips_hist_find_indexed()
.
[method]
vips_hist_find_indexed ()
int vips_hist_find_indexed (VipsImage *in
,VipsImage *index
,VipsImage **out
,...
);
Optional arguments:
combine
: VipsCombine, combine bins like this
Make a histogram of in
, but use image index
to pick the bins. In other
words, element zero in out
contains the combination of all the pixels in in
whose corresponding pixel in index
is zero.
index
must have just one band and be u8 or u16. in
must be
non-complex. out
always has the same size and format as in
.
Normally, bins are summed, but you can use combine
to set other combine
modes.
This operation is useful in conjunction with vips_labelregions()
. You can
use it to find the centre of gravity of blobs in an image, for example.
See also: vips_hist_find()
, vips_labelregions()
.
[method]
vips_hough_line ()
int vips_hough_line (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
width
: horizontal size of parameter spaceheight
: vertical size of parameter space
Find the line Hough transform for in
. in
must have one band. out
has one
band, with pixels being the number of votes for that line. The X dimension
of out
is the line angle in 0 - 180 degrees, the Y dimension is the
distance of the closest part of that line to the origin in the top-left.
Use width
height
to set the size of the parameter space image (out
),
that is, how accurate the line determination should be.
See also: vips_hough_circle()
.
[method]
vips_hough_circle ()
int vips_hough_circle (VipsImage *in
,VipsImage **out
,...
);
Optional arguments:
scale
: scale down dimensions by this muchmin_radius
: smallest radius to search formax_radius
: largest radius to search for
Find the circular Hough transform of an image. in
must be one band, with
non-zero pixels for image edges. out
is three-band, with the third channel
representing the detected circle radius. The operation scales the number of
votes by circle circumference so circles of differing size are given equal
weight.
The output pixel at (x, y, band) is the strength of the circle centred on (x, y) and with radius (band).
Use max_radius
and min_radius
to set the range of radii to search for.
Use scale
to set how in
coordinates are scaled to out
coordinates. A
scale
of 3, for example, will make out
1/3rd of the width and height of
in
, and reduce the number of radii tested (and hence the number of bands
int out
) by a factor of three as well.
See also: vips_hough_line()
.
[method]
vips_project ()
int vips_project (VipsImage *in
,VipsImage **columns
,VipsImage **rows
,...
);
Find the horizontal and vertical projections of an image, ie. the sum of every row of pixels, and the sum of every column of pixels. The output format is uint, int or double, depending on the input format.
Non-complex images only.
See also: vips_hist_find()
, vips_profile()
.
[method]
vips_profile ()
int vips_profile (VipsImage *in
,VipsImage **columns
,VipsImage **rows
,...
);
vips_profile() searches inward from the edge of in
and finds the
first non-zero pixel. Pixels in columns
have the distance from the top edge
to the first non-zero pixel in that column, rows
has the distance from the
left edge to the first non-zero pixel in that row.
See also: vips_project()
, vips_hist_find()
.
[method]
Types and Values
enum VipsOperationMath
See also: vips_math()
.